-
Notifications
You must be signed in to change notification settings - Fork 423
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
Key scopes are mixed when key is not present #98
Comments
That's how variable resolution is supposed to work. Mustache scope isn't a single scope, so much as a scope stack. So inside your <?php
[
['name' => 'password'],
[
'hidden' => true,
'fields' => [
0 => ['name' => 'email', 'hidden' => false],
1 => ['name' => 'password'],
2 => ['name' => 'session', 'hidden' => true]
],
[
'set' => [
'hidden' => true,
'fields' => [
0 => ['name' => 'email', 'hidden' => false],
1 => ['name' => 'password'],
2 => ['name' => 'session', 'hidden' => true]
]
]
]
]; It walks up the stack until it finds something with that name. The wiki has more info on this. The standard answer is to either always have your values set, or to name them differently. That said, you can often use dot notation to force resolution in the scope you want. In fact, it might not be too much of a stretch to say:
It might be worth trying to push that into spec |
Closing this one and opening an issue against the spec — mustache/spec#52 |
When I'm iterating over an array where the key are duplicated in different places, the rendering changes the scope if the key is not found. Take a look at this example:
I want the 'password' element to not be hidden because it doesn't have that property, the engine is reading the variable in 'set'.
The text was updated successfully, but these errors were encountered: