Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad subexpressions with subpath #786

Closed
victorenator opened this issue Apr 16, 2014 · 1 comment
Closed

Bad subexpressions with subpath #786

victorenator opened this issue Apr 16, 2014 · 1 comment

Comments

@victorenator
Copy link

Test

Handlebars.registerHelper('h1', function(a, b) {
    return 'h1 ' + a + ' ' + b;

});
Handlebars.registerHelper('eq', function(a, b) {
    return a === b;
});
Handlebars.compile('{{h1 (eq bar.abc.fgh 1) (eq bar.def 2)}}')({bar: {}})

returns

h1 [object Object] false

instead of

h1 false false

In compiled function:

function(depth0,helpers,partials,data) {
  var stack1, stack2, helper, helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
  stack1 = (helper = helpers.eq || (depth0 && depth0.eq) || helperMissing,helper.call(depth0, ((stack1 = ((stack1 = (depth0 && depth0.bar)),stack1 == null || stack1 === false ? stack1 : stack1.abc)),stack1 == null || stack1 === false ? stack1 : stack1.fgh), 1, {"name":"eq","hash":{},"data":data}));
  stack2 = (helper = helpers.eq || (depth0 && depth0.eq) || helperMissing,helper.call(depth0, ((stack1 = (depth0 && depth0.bar)),stack1 == null || stack1 === false ? stack1 : stack1.def), 2, {"name":"eq","hash":{},"data":data}));
  return escapeExpression((helper = helpers.h1 || (depth0 && depth0.h1) || helperMissing,helper.call(depth0, stack1, stack2, {"name":"h1","hash":{},"data":data})));
  }

stack1 variable is rewritten in the expression stack2

@kpdecker
Copy link
Collaborator

I believe this is the same issue as #800 and a few others. This should be fixed in master. Please let me know if you're still seeing this issue in master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants