Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 31 lines (20 sloc) 0.884 kb
6aa657e @groue guides wip
authored
1 [up](../runtime.md), [next](booleans.md)
2
1a1555f @groue guides wip
authored
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
17 Arrays of scalar values
18 -----------------------
19
20 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.
21
03d4645 @groue guides wip
authored
22 For instance, the following template can render `{ items: ['ham', 'jam'] }`:
1a1555f @groue guides wip
authored
23
24 <ul>
25 {{#items}}
26 <li>{{.}}</li>
27 {{/items}}
28 </ul>
29
6aa657e @groue guides wip
authored
30 [up](../runtime.md), [next](booleans.md)
Something went wrong with that request. Please try again.