Comparing version 2.3.1 to 2.4.0
17
index.js
@@ -18,4 +18,11 @@ /*jshint node: true*/ | ||
hbTraverse(tree, function(node) { | ||
// handlebars 3,4 | ||
if (node.type === 'PartialStatement') { | ||
partials.push(node.name.original); | ||
return | ||
} | ||
// handlebars 2 | ||
if (node.type === 'partial') { | ||
partials.push(node.partialName); | ||
partials.push(node.partialName.name); | ||
return; | ||
} | ||
@@ -66,2 +73,4 @@ }); | ||
opts = opts || {}; | ||
if (opts) { | ||
@@ -104,3 +113,3 @@ if (opts.e || opts.extensions) { | ||
js = precompiler.precompile(buffer, opts && opts.precompilerOptions); | ||
js = precompiler.precompile(buffer, opts.precompilerOptions); | ||
} catch (e) { | ||
@@ -117,4 +126,4 @@ this.emit('error', e); | ||
var ident = "partial$" + i; | ||
compiled += "var " + ident + " = require('" + p.name + "');\n"; | ||
compiled += "HandlebarsCompiler.registerPartial('" + p.name + "', " + ident + ");\n"; | ||
compiled += "var " + ident + " = require('" + p + "');\n"; | ||
compiled += "HandlebarsCompiler.registerPartial('" + p + "', " + ident + ");\n"; | ||
}); | ||
@@ -121,0 +130,0 @@ } |
{ | ||
"name": "hbsfy", | ||
"version": "2.3.1", | ||
"version": "2.4.0", | ||
"description": "Handlebars precompiler plugin for Browserify v2", | ||
@@ -30,5 +30,5 @@ "main": "index.js", | ||
"concat-stream": "~1.4.1", | ||
"ember-template-compiler": "^1.6.1", | ||
"handlebars": "~1.3.0" | ||
"ember-template-compiler": "github:toranb/ember-template-compiler#b924608f", | ||
"handlebars": "^4" | ||
} | ||
} |
@@ -167,2 +167,10 @@ [![Build Status](https://travis-ci.org/epeli/node-hbsfy.png?branch=master)](https://travis-ci.org/epeli/node-hbsfy) | ||
### 2.4.0 | ||
- support handlebars 2, 3, 4 | ||
### 2.3.1 | ||
- Handle `null` nodes when traversing Handlebars AST. | ||
### 2.3.0 | ||
@@ -169,0 +177,0 @@ |
@@ -18,4 +18,3 @@ | ||
b.bundle().pipe(concat(function(data) { | ||
console.log("Bundle size", data.length); | ||
assert(data.length < 20000, "Bundle is too big! Maybe full Handlebars got compiled in?"); | ||
assert(data.length < 35000, "Bundle is too big! Maybe full Handlebars got compiled in?"); | ||
vm.runInNewContext(data.toString(), context); | ||
@@ -22,0 +21,0 @@ })); |
@@ -11,6 +11,11 @@ var hbsfy = require("hbsfy"); | ||
.pipe(concat(function(data) { | ||
assert( | ||
/helperMissing\.call/.test(data.toString()), | ||
"The helperMissing call is present" | ||
); | ||
// module.exports = template | ||
eval(data); | ||
try { | ||
module.exports(); | ||
} catch (e) { | ||
assert(e.message.indexOf('Missing helper') > -1, 'Missing helper error'); | ||
assert(e.message.indexOf('upcase' > -1), 'missing helper is named'); | ||
} | ||
})); | ||
@@ -30,6 +35,11 @@ | ||
.pipe(concat(function(data) { | ||
assert( | ||
!/helperMissing\.call/.test(data.toString()), | ||
"The helperMissing call should not be present" | ||
); | ||
// module.exports = template | ||
eval(data); | ||
try { | ||
module.exports(); | ||
} catch (e) { | ||
assert.equal(e.message, | ||
'Cannot read property \'call\' of undefined'); | ||
} | ||
})); |
@@ -11,3 +11,3 @@ | ||
fs.createReadStream(templatePath) | ||
.pipe(hbsfy(templatePath, { precompiler: "ember-template-compiler" })) | ||
.pipe(hbsfy(templatePath, { precompiler: "ember-template-compiler", precompilerOptions: false })) | ||
.pipe(concat(function(data) { | ||
@@ -14,0 +14,0 @@ assert( |
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
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
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
32699
672
219
2