-
Notifications
You must be signed in to change notification settings - Fork 4
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
Each not pushing on a context level #57
Comments
Uh, this is missing some context. Can you state the inputs to this template? Edit: I'm assuming a structure like: {
"foo": [
{ "title": "hi", "bar": [{ "ignored": true }] }
]
} |
AFAICT it's missing a {{#each foo as |f| }}
{{#each f.bar as |b| }}
{{ f.title }}
{{ ../title }}
{{/each}}
{{/each}} Note! My example above works on tryhandlebars. Yes, that's right: it's scoped ( |
Shorter failing case we can't currently work around AFAIK (because a workaround for BMX would break Handlebars version, and vice-versa): {{ title }}
{{#each foo }}
{{ ../title }}
{{/each}} {
"title": "hi",
"foo": [{}]
} |
Yeah, sorry your last test case is actually the one I hit (so couldn't even assign a name to the other context). Thanks for filling in more details. |
I don't follow, why would each push a new context? all it does is define 'this' and some data variables What does handlebars do? |
yep you can just wrap it in |
Take this example that I tried on tryhandlebars: {{#each foo as |f| }}
{{#each f.bar as |b| }}
{{#each b.quux as |c| }}
-{{ f.title }}- {{!-- ../../f.title doesn't work --}}
={{ ../../title }}= {{!-- title doesn't work, neither does ../title --}}
{{/each}}
{{/each}}
{{/each}} { "foo": [
{
"title": "hi",
"bar": [
{ "quux": [{}] }
]
}
]} |
So I think an even simpler case that I just hit was:
|
That's definitely a simple way to demonstrate the not-pushing-a-scope-ness. The real kicker about this bug is that we're damned if we push a scope (an |
@damncabbage Interestingly I use an explicit this successfully in a non-bikeshed context, just using bmx https://github.com/ambiata/boris/blob/master/boris-http/template/builds.hbs#L32-L36 I am kind of surprised that works when others fail. |
Just confirming what y'all have probably figured out by now: The current implementation of {{each foo}}
{{this.bar}}
{{this.baz}}
{{/each}} This is a mistake, a bug for sure. Anything that gets rid of I think we should stick to a definition that keeps us mustache-compliant, i.e. fix the JS block parameter scoping insanity and then make BMX push a context. |
../title
will blow up, buttitle
works fineThe text was updated successfully, but these errors were encountered: