diff options
author | Marcio Junior <marciojunior_eu@yahoo.com.br> | 2015-02-08 19:31:27 -0200 |
---|---|---|
committer | Marcio Junior <marciojunior_eu@yahoo.com.br> | 2015-02-08 19:31:38 -0200 |
commit | 07f27843dc01058103d084c18a5db297b150d9cb (patch) | |
tree | 4a87695006825861b0815c4fd2830d9760ab055d /lib/handlebars/compiler/compiler.js | |
parent | 5cc326d42554da8a00c69d8a8c6a71e3e6a61371 (diff) | |
download | handlebars.js-07f27843dc01058103d084c18a5db297b150d9cb.zip handlebars.js-07f27843dc01058103d084c18a5db297b150d9cb.tar.gz handlebars.js-07f27843dc01058103d084c18a5db297b150d9cb.tar.bz2 |
Transform literals to path expressions in mustache nodes
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 75b2c1b..605a54b 100644 --- a/lib/handlebars/compiler/compiler.js +++ b/lib/handlebars/compiler/compiler.js @@ -172,11 +172,8 @@ Compiler.prototype = { }, MustacheStatement: function(mustache) { - if (!mustache.path.type.match(/Literal$/)) { - this.SubExpression(mustache); - } else { - this.accept(mustache.path); - } + transformLiteralToPath(mustache); + this.SubExpression(mustache); if(mustache.escaped && !this.options.noEscape) { this.opcode('appendEscaped'); @@ -489,3 +486,10 @@ function argEquals(a, b) { return true; } } + +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 }; + } +} |