Examples

Context variables

↑
The context is a JavaScript object containing variables that can be used in the template. If you pass this object to the template
    
    {
        firstName: 'Jack',
        lastName: 'Shephard',
        status: 'lost',
    }
    
  
you can use it in the template as follows:
    
    <h3>Passenger information:</h3>
    <div>Name: {{ lastName }}, {{ firstName }}</div>
    <div>Status: {{ status }}</div>
    
  
The final result will be this:

Passenger information:

Name: Shephard, Jack
Status: lost

Context loops

↑
As well as being able to inject simple variables, you can also pass arrays (of values of simple types) to the template. In the template, you can iterate these arrays:
    
    { passengers:
      [
        'Jack',
        'John',
        'Kate',
        'Sawyer',
        'Hurley',
        'Sayid',
        'Charlie',
        'Claire',
        'Michael',
        'Shannon',
        'Jin-Soo',
        'Sun-Hwa',
        'Boone',
        'Walter',
      ]
    };
    
  

you can use it like this in the template:

  
    <h3>Passengers</h3>
    <ol>
      {% for passenger in passengers %}
        <li>{{ passenger }}</li>
      {% endfor %}
    </ol>
  
  

This renders to:

Passengers

  1. Jack
  2. John
  3. Kate
  4. Sawyer
  5. Hurley
  6. Sayid
  7. Charlie
  8. Claire
  9. Michael
  10. Shannon
  11. Jin-Soo
  12. Sun-Hwa
  13. Boone
  14. Walter

From DB

Kate Austen
Claire Littleton
Sun-Hwa Kwon

Nested properties

John Locke