summaryrefslogtreecommitdiffstats
path: root/lib/handlebars/compiler/compiler.js
diff options
context:
space:
mode:
authorKevin Decker <kpdecker@gmail.com>2014-07-06 23:56:33 -0500
committerKevin Decker <kpdecker@gmail.com>2014-07-06 23:56:33 -0500
commit9a1eda2caff7a5eadc43fbb89db44c0205c6c03e (patch)
tree08f036fce72b0e0f1c700383cdba1d13033334ec /lib/handlebars/compiler/compiler.js
parent054627adb0441fbd4622ab3bd6c5d94e63dc4088 (diff)
parentb5a5c76ceb85fee36340e14b79306a436d32ff72 (diff)
downloadhandlebars.js-9a1eda2caff7a5eadc43fbb89db44c0205c6c03e.zip
handlebars.js-9a1eda2caff7a5eadc43fbb89db44c0205c6c03e.tar.gz
handlebars.js-9a1eda2caff7a5eadc43fbb89db44c0205c6c03e.tar.bz2
Merge pull request #731 from wycats/path-lookup
Strange behavior for {{#foo}} {{bar}} {{/foo}} when foo is 0
Diffstat (limited to 'lib/handlebars/compiler/compiler.js')
-rw-r--r--lib/handlebars/compiler/compiler.js15
1 files changed, 5 insertions, 10 deletions
diff --git a/lib/handlebars/compiler/compiler.js b/lib/handlebars/compiler/compiler.js
index e5f2280..31176c9 100644
--- a/lib/handlebars/compiler/compiler.js
+++ b/lib/handlebars/compiler/compiler.js
@@ -275,6 +275,8 @@ Compiler.prototype = {
} else if (this.options.knownHelpersOnly) {
throw new Exception("You specified knownHelpersOnly, but used the unknown helper " + name, sexpr);
} else {
+ id.falsy = true;
+
this.ID(id);
this.opcode('invokeHelper', params.length, id.original, sexpr.isRoot);
}
@@ -298,23 +300,16 @@ Compiler.prototype = {
var name = id.parts[0];
if (!name) {
+ // Context reference, i.e. `{{foo .}}` or `{{foo ..}}`
this.opcode('pushContext');
} else {
- this.opcode('lookupOnContext', id.parts[0]);
- }
-
- for(var i=1, l=id.parts.length; i<l; i++) {
- this.opcode('lookup', id.parts[i]);
+ this.opcode('lookupOnContext', id.parts, id.falsy);
}
},
DATA: function(data) {
this.options.data = true;
- this.opcode('lookupData', data.id.depth);
- var parts = data.id.parts;
- for(var i=0, l=parts.length; i<l; i++) {
- this.opcode('lookup', parts[i]);
- }
+ this.opcode('lookupData', data.id.depth, data.id.parts);
},
STRING: function(string) {