-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Scoping issue for the internal keys that have the same name as a key in the parent object #342
Comments
We ran into this bug this morning. Currently we can workaround, but that's not a long-term solution. |
That's not a bug. That's how the context stack works in Mustache. It's in the spec, and it's on purpose, and you would complain even more if it didn't :) For a (php flavored) explanation of how the context stack works, see variable resolution on the mustache.php wiki. |
Hmm, okay, I accept your point. It seems that for simplicity's sake, the language is slightly flawed in that variable scope is vague - expecting it to behave like other loops may be too much, e.g.
|
As @bobthecow already pointed out, this is a feature, not a bug. Closing. |
See mustache/spec#52 for a proposed feature that makes this a lot easier to work with. |
When there are nested objects, it is not possible to have similar names for the keys.
Look at the following example where Anna has 4 children and one of her children has 3 children and we want to render them in a menu structure:
It gives the following HTML output:
But it is only Harold that has children not John, Richard or Betty. In other words if a collection doesn't exist it shouldn't be rendered using data from one scope higher! This is unexpected behaviour for Mustache and is wrong no matter what the technical implications are.
The text was updated successfully, but these errors were encountered: