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

Handlebars "this" path referring to helper #1143

Closed
awwx opened this Issue Jun 11, 2013 · 2 comments

Comments

Projects
None yet
3 participants
@awwx
Contributor

awwx commented Jun 11, 2013

https://github.com/meteor/meteor/wiki/Handlebars#expressions-with-dots states:

Paths starting with this always refer to properties of the current data context and not to helpers.

But

<body>
  {{> hello}}
</body>

<template name="hello">
  {{#each stuff}}
    {{this.title}}
  {{/each}}
</template>


if (! Meteor.isClient)
  return;

Stuff = new Meteor.Collection(null);
Stuff.insert({title: "One"});
Stuff.insert({title: "Two"});
Stuff.insert({title: "Three"});

Handlebars.registerHelper("title", function() {
  return "hello!";
});

Template.hello.stuff = function() {
  return Stuff.find();
};

displays "One hello! hello!" instead of "One Two Three" in Meteor 0.6.4.

@dgreensp

This comment has been minimized.

Contributor

dgreensp commented Jun 20, 2013

Found the bug! When we're walking the template AST, we mutate it in place by accident (oops). Fixing on devel.

@funkyeah

This comment has been minimized.

funkyeah commented Jun 27, 2013

I can't explain it but in some weird way it makes me happy to know that my noob filled stackoverflow question lead to @awwx filing a bug, which lead to @dgreensp finding and fixing a bug, all so that I didn't have to change the name of a helper.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment