-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[bug] HB doesn't iterate over array returned by function #243
Comments
My understanding is that Handlebars isn't meant to support function properties. |
Hmmm, not sure about it, it support {{myModel.someAttributeAsFunction}} for example. |
My understanding is that it will work in some cases but isn't recommended. I may be mistaken though. |
handlebars (at least outside of Ember.js) doesn't officially support functions as properties. You could do this even though it's really janky: var context = {
people: (function(){return [{name: 'Jim'}, {name: 'John'}]})()
} see: |
Why not? Is there any reason for such limitation? It doesn't complicate syntax or API of mustache and seems perfectly valid and clear use case, why not support it? It seems that it's not actually a related issue, there's the discussion about the context of function, not about should it be called or not. |
i don't necessarily disagree with it, especially since you can do computed props in Ember. I'm sure Yehuda has a much better reason. |
In Ember we actually modify the default Handlebars behavior to change it. If you want this sort of support, you should consider looking at what Ember does. I don't forsee the default Handlebars behavior changing any time soon so I'm closing this. |
It seems that Handlebars doesn't iterate over array returned by function, it threats it as
if
statement.Test case:
The result will be
peoples: name:
instead ofpeoples: name: Jim name: John
.Try it online http://jsfiddle.net/HUcNP/
The text was updated successfully, but these errors were encountered: