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
Add support for nesting stache helpers #1769
Comments
+1 I'd like this. |
The place to start implementing this is to first get the parsing of sub-expressions working. Currently, the parsing happens here: https://github.com/bitovi/canjs/blob/master/view/stache/mustache_core.js#L133 For something like {
name: "outer-helper",
args: [1, {get: 'name'}],
hashes: {zed: 'ted', foo: {get: 'bar'}}
} To make sub-expressions work, we'd want to make this recursive. Something like
With that in place, the next work would need to be done in makeEvaluator: https://github.com/bitovi/canjs/blob/master/view/stache/mustache_core.js#L182 There is looks in args and in hashes for objects "getter" objects: https://github.com/bitovi/canjs/blob/master/view/stache/mustache_core.js#L208 If it found an object like {name, args, hashes}, it could actually call itself (makeEvaluator) with that object as All in all .. pretty simple actually. |
Related to #1888, I'm thinking that function calls are more natural when you might have multiple of them. Compare:
vs
|
I like the function call method |
This works now, with helpers and functions. I think it was added via #1832. Working example with |
Handlebars supports putting the result of one stache helper in another. They call it Subexpressions.
Angular also allows chaining filters but there is currently no way to do this type of thing in the CanJS implementation of mustache/stache.
The text was updated successfully, but these errors were encountered: