how to call array filter within ractivejs template -
so don't want use data functions (let's want final user interact templates , not hardcode javascript.) if had array n elements how can filter can m elements within ractive template ? right have code >> http://jsfiddle.net/t168vymw/4/ not working correctly.
requirements: cannot use function filter, data: {filtersomething: function(){...} }
instead, let user play complex array function convertions template. ractive yet supporting ?
ractive doesn't support involves function
keyword inside expressions, there 3 ways this:
- data functions,
- method calls (calling methods of ractive instance inside template),
- filtering data directly in template.
you said want logic in template leaves option #3. example, if wanted display numbers list, this:
{{ #a }} {{ #!(this % 2) }} {{ }} {{/}} {{ /a }}
however, considered anti-pattern. it's better idea allow user write custom js or provide them prepared functions can use in template.
Comments
Post a Comment