Skip to content
Newer
Older
100644 33 lines (21 sloc) 1.01 KB
6aa657e @groue guides wip
authored Jan 25, 2012
1 [up](../runtime.md), [next](booleans.md)
2
1a1555f @groue guides wip
authored Jan 25, 2012
3 Mustache loops
4 ==============
5
6 Mustache sections that are provided with an enumerable object will be rendered once for each item in it.
7
8 Those are all objects conforming to the NSFastEnumeration protocol, but NSDictionary. The most obvious enumerable is NSArray.
9
10 Each item enters the context stack on its turn. Below, the `name` key will be looked in each item:
11
12 My shopping list:
13 {{#items}}
14 - {{name}}
15 {{/items}}
16
4f79605 @groue Document the rendering of lists by variable tags.
authored Sep 29, 2012
17 Mustache variable tags such as `{{items}}` can also be given an enumerable object: they then render the concatenation of the rendering of each item.
18
19 Lists of scalar values
20 ----------------------
1a1555f @groue guides wip
authored Jan 25, 2012
21
22 The "implicit iterator" `{{.}}` tag will help you iterating arrays of strings or numbers, generally objects that don't have any dedicated key for rendering themselves.
23
03d4645 @groue guides wip
authored Jan 26, 2012
24 For instance, the following template can render `{ items: ['ham', 'jam'] }`:
1a1555f @groue guides wip
authored Jan 25, 2012
25
26 <ul>
27 {{#items}}
28 <li>{{.}}</li>
29 {{/items}}
30 </ul>
31
6aa657e @groue guides wip
authored Jan 25, 2012
32 [up](../runtime.md), [next](booleans.md)
Something went wrong with that request. Please try again.