-
Notifications
You must be signed in to change notification settings - Fork 421
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
Dynamic property access with mustache and stache #1157
Comments
That seems fine to me. @andykant ? I would check mustache / Handlebars for any existing conventions. Added this to the 2.2 milestone. |
http://handlebarsjs.com/builtin_helpers.html Mentions a helper called {{#each (lookup things key)}}
...
{{/each}} Either way, probably good for us to include the |
Closing for: canjs/can-stache#7 |
VOTE HERE
I've been working on converting a lot of
EJS
templates tomustache
recently, and have found one particular pattern that I think might be worth addressing with a built-in solution.Right now, without writing your own helper, you can't access a data property in mustache based on another property in the scope. Something like
<%= car.attr(part); %>
inEJS
has no direct equivalent inmustache
. To pull off the same task, you would need to write a helper, but that is only of limited utility.This, for example, would still be fairly hard to translate:
My first instinct is to propose a syntax extension that follows JavaScript conventions for dynamic field access:
obj[key]
, so you would be able to write the following to translate the above without losing the utility of#each
:The text was updated successfully, but these errors were encountered: