diff options
Diffstat (limited to 'lib/handlebars/compiler/compiler.js')
-rw-r--r-- | lib/handlebars/compiler/compiler.js | 14 |
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); } } |