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

Handlebars #unless creates new data context visible to .. #562

Closed
cscott opened this issue Dec 19, 2012 · 1 comment
Closed

Handlebars #unless creates new data context visible to .. #562

cscott opened this issue Dec 19, 2012 · 1 comment

Comments

@cscott
Copy link

cscott commented Dec 19, 2012

Meteor's implementation of .. in block helpers appears to differ from handlebar's. The handlebars documentation says,

The ../ path segment references the parent template scope, not one level up in the context. This is because block helpers can invoke a block with any context, so the notion of "one level up" isn't particularly meaningful except as a reference to the parent template scope.

but in meteor, {{#unless}} (and presumably {{#if}} as well, though I didn't test this specifically) creates a new data context, and .. refers to the block context chain. Thus, the following behaves surprisingly:

{{#with doc}}
    {{> template1}}
{{/with}}
<template name="template1">
<p>This is what we expect -- the id of doc: {{_id}}</p>
{{#each array_field_of_doc}}}
<p>This is also what we expect -- the id of doc {{../_id}}</p>
{{#unless false}}
<p>This is unexpectedly undefined: {{../_id}}</p>
<p>This is how you have to get the id of doc: {{../../_id}}</p>
{{/unless}}
{{/each}}
</template>
@dgreensp
Copy link
Contributor

Meteor's implementation of .. was never very good.

Meteor's template language is morphing at the moment. Instead of .., we'll have ways of accessing named data in enclosing templates. We'll also better-document the behavior of syntax like this.

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