inline-source
Advanced tools
Comparing version 0.2.0 to 0.3.0
12
index.js
@@ -12,5 +12,6 @@ var path = require('path') | ||
* Parse 'html' for <script> and <link> tags containing an 'inline' attribute | ||
* @param {String} htmlpath | ||
* @param {String} html | ||
*/ | ||
module.exports = function(html) { | ||
module.exports = function(htmlpath, html) { | ||
var match; | ||
@@ -20,3 +21,3 @@ | ||
while (match = RE_INLINE_SOURCE.exec(html)) { | ||
html = inline('js', match[1], html); | ||
html = inline('js', match[1], htmlpath, html); | ||
} | ||
@@ -26,3 +27,3 @@ | ||
while (match = RE_INLINE_HREF.exec(html)) { | ||
html = inline('css', match[1], html); | ||
html = inline('css', match[1], htmlpath, html); | ||
} | ||
@@ -37,6 +38,7 @@ | ||
* @param {String} source | ||
* @param {String} htmlpath | ||
* @param {String} html | ||
* @returns {String} | ||
*/ | ||
function inline(type, source, html) { | ||
function inline(type, source, htmlpath, html) { | ||
var isCSS = (type == 'css') | ||
@@ -46,3 +48,3 @@ , tag = isCSS ? 'style' : 'script' | ||
// Parse url | ||
, filepath = path.resolve(source.match(isCSS ? RE_HREF : RE_SRC)[1]) | ||
, filepath = path.resolve(path.extname(htmlpath).length ? path.dirname(htmlpath) : htmlpath, source.match(isCSS ? RE_HREF : RE_SRC)[1]) | ||
, filecontent; | ||
@@ -49,0 +51,0 @@ |
{ | ||
"name": "inline-source", | ||
"description": "Inline all flagged js & css source files", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"author": "popeindustries <alex@pope-industries.com>", | ||
@@ -6,0 +6,0 @@ "keywords": ["inline", "html", "js", "css"], |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2863
57