i had write this on mustache.html on couchapp
**{{%IMPLICIT-ITERATOR iterator=i}} {{#example}}
hallo {{i}}
{{/example}}**
with this array
{ "example": ["alpha","beta","gamma","delta"] }
but the result from couchapp is like this
hallo alpha,beta,gamma,delta
hallo alpha,beta,gamma,delta
hallo alpha,beta,gamma,delta
hallo alpha,beta,gamma,delta
how can i get just hallo beta and hallo delta?
Thank开发者_JS百科s
This is one area where if you are not used to the "logic-less" templating, it can feel like you have some handcuffs. In short, if you just want to render a subset of an array in mustache, then you need to provide an array with just those elements you want to display.
AFAIK, there is no way to put conditional logic of the form "if element is 'a' print it, otherwise don't print it". Of course, mustache provides some conditional execution based on if data is present or not (e.g. the {{^ foo}} statement). More fine tuned/complicated display logic is not possible.
精彩评论