summaryrefslogtreecommitdiffstats
path: root/lib/handlebars/compiler/compiler.js
diff options
context:
space:
mode:
authorkpdecker <kpdecker@gmail.com>2015-02-09 23:54:46 -0600
committerkpdecker <kpdecker@gmail.com>2015-02-09 23:54:46 -0600
commit39121cf8f50ec02b5a979f4911caefef8030161a (patch)
treed73b514d22c9a66dc3d01b232d1bda8176f56d7e /lib/handlebars/compiler/compiler.js
parent07f27843dc01058103d084c18a5db297b150d9cb (diff)
downloadhandlebars.js-39121cf8f50ec02b5a979f4911caefef8030161a.zip
handlebars.js-39121cf8f50ec02b5a979f4911caefef8030161a.tar.gz
handlebars.js-39121cf8f50ec02b5a979f4911caefef8030161a.tar.bz2
Handle all potential literal values
Adds support for literal helper names in a few missing cases such as block expressions and subexpressions.
Diffstat (limited to 'lib/handlebars/compiler/compiler.js')
-rw-r--r--lib/handlebars/compiler/compiler.js14
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/handlebars/compiler/compiler.js b/lib/handlebars/compiler/compiler.js
index 605a54b..21de99c 100644
--- a/lib/handlebars/compiler/compiler.js
+++ b/lib/handlebars/compiler/compiler.js
@@ -110,6 +110,8 @@ Compiler.prototype = {
},
BlockStatement: function(block) {
+ transformLiteralToPath(block);
+
var program = block.program,
inverse = block.inverse;
@@ -172,7 +174,6 @@ Compiler.prototype = {
},
MustacheStatement: function(mustache) {
- transformLiteralToPath(mustache);
this.SubExpression(mustache);
if(mustache.escaped && !this.options.noEscape) {
@@ -191,6 +192,7 @@ Compiler.prototype = {
CommentStatement: function() {},
SubExpression: function(sexpr) {
+ transformLiteralToPath(sexpr);
var type = this.classifySexpr(sexpr);
if (type === 'simple') {
@@ -487,9 +489,11 @@ function argEquals(a, b) {
}
}
-function transformLiteralToPath(mustache) {
- if (mustache.path.type.match(/Literal$/)) {
- var literal = mustache.path;
- mustache.path = { type: 'PathExpression', original: String(literal.original), parts: [String(literal.original)], depth: 0, data: false };
+function transformLiteralToPath(sexpr) {
+ if (!sexpr.path.parts) {
+ var literal = sexpr.path;
+ // Casting to string here to make false and 0 literal values play nicely with the rest
+ // of the system.
+ sexpr.path = new AST.PathExpression(false, 0, [literal.original+''], literal.original+'', literal.log);
}
}