Mustache: How to test for existence without iteration
In Mustache templates, sometimes you just want to test if an array exists, without iterating over it. However, {{#myArray}}...{{/myArray}} will iterate over myArray. What if you just want to check if myArray exists?
Solution: {{#myArray.0}}...{{/myArray.0}}
This will operate on the first (i.e., 0th) element of myArray.
0 Comments:
Post a Comment
<< Home