-
Notifications
You must be signed in to change notification settings - Fork 396
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
Object iteration doesn't work if key contains dots #396
Comments
Note to self... update http://docs.ractivejs.org/latest/mustaches if this turns out to be a wontfix! |
Yeah, this is a wontfix... I can't think of a way to allow dots in keys that wouldn't screw things up for everyone. In a very old version of Ractive there was a But I fixed the docs at least! |
Is is possible to create some syntax to iterate over an Object's values rather than its keys? For example:
Or does that succumb to the same inherit problem? It's similar to iterating over an array, but if the user's data is in Object form anyway, it'll save some cpu cycles converting back and forth between arrays/objects |
Simply like that:
|
Hmmm... am I missing something? I tried both with/without .'s in the keys: http://jsfiddle.net/zT5q2/ |
My bad, forgot the iterator index. You actually need that for object iteration.
The dots in |
Right... So back to my original question. Could the problem be worked around with some new syntax that doesn't consider keys, and instead just iterates through object values? It's a lot of extra work for an edge case, just wondering if it's possible. |
@j1mmie - yes, @skeptic35's answer is correct in that the presence of the Inside the section, you can use {{#numbers:name}}
<p>{{name}}: {{this}}</p>
{{/numbers}} ractive = new Ractive({
...
data: {
numbers: {
one: 1,
two: 2,
three: 3
}
}
}); ...results in... <p>one: 1</p>
<p>two: 2</p>
<p>three: 3</p> |
Maybe I'm miscommunicating - I'm asking if developing a new syntax could provide a workaround for issue #396 "Object iteration doesn't work if key contains dots" Is it possible to develop a new syntax that does that? I'm not asking if one exists, or how to iterate over keys, etc. I'm wondering if, if a developer were so inclined, a syntax could be developed to iterate over values, rather than keys. |
As mentioned in #115, object iteration doesn't work if key contains dots.
The text was updated successfully, but these errors were encountered: