Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

33 lines (21 sloc) 1.032 kb

up, next

Mustache loops

Mustache sections that are provided with an enumerable object will be rendered once for each item in it.

Those are all objects conforming to the NSFastEnumeration protocol, but NSDictionary. The most obvious enumerable is NSArray.

Each item enters the context stack on its turn. Below, the name key will be looked in each item:

My shopping list:
{{#items}}
- {{name}}
{{/items}}

Mustache variable tags such as {{items}} can also be given an enumerable object: they then render the concatenation of the rendering of each item.

Lists of scalar values

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.

For instance, the following template can render { items: ['ham', 'jam'] }:

<ul>
{{#items}}
    <li>{{.}}</li>
{{/items}}
</ul>

up, next

Jump to Line
Something went wrong with that request. Please try again.