Loading...

Some mustache examples for the beginning

Data Structure

A collection or list can be listed iteratively using the # as start and / as end.

For instance:


{{#lines}}
 ...
{{/lines}}

You could use for listing order or delivery positions. A simple example, a contact person has multiple phone numbers.

Template


{{contact.name}}
{{#contact.phone_numbers}}
* {{type}}: {{value}}
{{/contact.phone_numbers}}

Data

{
  "contact": {
    "name": "Le Mapper",
    "phone_numbers": [
      {
        "type": "office",
        "value": "+41 12 34 56 78"
      },
      {
        "type": "private",
        "value": "+79 12 34 56 78"
      }
    ]
  }
}

Output

Le Mapper
* office: +41 12 34 56 78
* private: +79 12 34 56 78