| @@ -66,6 +66,13 @@ All variables are HTML-escaped by default. If you want to render unescaped HTML, | |||||
| use the triple mustache: `{{{name}}}`. You can also use `&` to unescape a | use the triple mustache: `{{{name}}}`. You can also use `&` to unescape a | ||||
| variable. | variable. | ||||
| View: | |||||
| { | |||||
| "name": "Chris", | |||||
| "company": "<b>GitHub</b>" | |||||
| } | |||||
| Template: | Template: | ||||
| * {{name}} | * {{name}} | ||||
| @@ -74,13 +81,6 @@ Template: | |||||
| * {{{company}}} | * {{{company}}} | ||||
| * {{&company}} | * {{&company}} | ||||
| View: | |||||
| { | |||||
| "name": "Chris", | |||||
| "company": "<b>GitHub</b>" | |||||
| } | |||||
| Output: | Output: | ||||
| * Chris | * Chris | ||||
| @@ -92,11 +92,6 @@ Output: | |||||
| JavaScript's dot notation may be used to access keys that are properties of | JavaScript's dot notation may be used to access keys that are properties of | ||||
| objects in a view. | objects in a view. | ||||
| Template: | |||||
| * {{name.first}} {{name.last}} | |||||
| * {{age}} | |||||
| View: | View: | ||||
| { | { | ||||
| @@ -107,6 +102,11 @@ View: | |||||
| "age": "RIP" | "age": "RIP" | ||||
| } | } | ||||
| Template: | |||||
| * {{name.first}} {{name.last}} | |||||
| * {{age}} | |||||
| Output: | Output: | ||||
| * Michael Jackson | * Michael Jackson | ||||
| @@ -128,6 +128,12 @@ The behavior of the section is determined by the value of the key. | |||||
| If the `person` key exists and has a value of `null`, `undefined`, or `false`, | If the `person` key exists and has a value of `null`, `undefined`, or `false`, | ||||
| or is an empty list, the block will not be rendered. | or is an empty list, the block will not be rendered. | ||||
| View: | |||||
| { | |||||
| "person": false | |||||
| } | |||||
| Template: | Template: | ||||
| Shown. | Shown. | ||||
| @@ -135,12 +141,6 @@ Template: | |||||
| Never shown! | Never shown! | ||||
| {{/person}} | {{/person}} | ||||
| View: | |||||
| { | |||||
| "person": false | |||||
| } | |||||
| Output: | Output: | ||||
| Shown. | Shown. | ||||
| @@ -154,12 +154,6 @@ When the value is a list, the block is rendered once for each item in the list. | |||||
| The context of the block is set to the current item in the list for each | The context of the block is set to the current item in the list for each | ||||
| iteration. In this way we can loop over collections. | iteration. In this way we can loop over collections. | ||||
| Template: | |||||
| {{#stooges}} | |||||
| <b>{{name}}</b> | |||||
| {{/stooges}} | |||||
| View: | View: | ||||
| { | { | ||||
| @@ -170,6 +164,12 @@ View: | |||||
| ] | ] | ||||
| } | } | ||||
| Template: | |||||
| {{#stooges}} | |||||
| <b>{{name}}</b> | |||||
| {{/stooges}} | |||||
| Output: | Output: | ||||
| <b>Moe</b> | <b>Moe</b> | ||||
| @@ -179,18 +179,18 @@ Output: | |||||
| When looping over an array of strings, a `.` can be used to refer to the current | When looping over an array of strings, a `.` can be used to refer to the current | ||||
| item in the list. | item in the list. | ||||
| Template: | |||||
| {{#musketeers}} | |||||
| * {{.}} | |||||
| {{/musketeers}} | |||||
| View: | View: | ||||
| { | { | ||||
| "musketeers": ["Athos", "Aramis", "Porthos", "D'Artagnan"] | "musketeers": ["Athos", "Aramis", "Porthos", "D'Artagnan"] | ||||
| } | } | ||||
| Template: | |||||
| {{#musketeers}} | |||||
| * {{.}} | |||||
| {{/musketeers}} | |||||
| Output: | Output: | ||||
| * Athos | * Athos | ||||
| @@ -201,12 +201,6 @@ Output: | |||||
| If the value of a section variable is a function, it will be called in the | If the value of a section variable is a function, it will be called in the | ||||
| context of the current item in the list on each iteration. | context of the current item in the list on each iteration. | ||||
| Template: | |||||
| {{#beatles}} | |||||
| * {{name}} | |||||
| {{/beatles}} | |||||
| View: | View: | ||||
| { | { | ||||
| @@ -221,6 +215,12 @@ View: | |||||
| } | } | ||||
| } | } | ||||
| Template: | |||||
| {{#beatles}} | |||||
| * {{name}} | |||||
| {{/beatles}} | |||||
| Output: | Output: | ||||
| * John Lennon | * John Lennon | ||||
| @@ -235,10 +235,6 @@ literal block of text, un-rendered, as its first argument. The second argument | |||||
| is a special rendering function that uses the current view as its view argument. | is a special rendering function that uses the current view as its view argument. | ||||
| It is called in the context of the current view object. | It is called in the context of the current view object. | ||||
| Template: | |||||
| {{#bold}}Hi {{name}}.{{/bold}} | |||||
| View: | View: | ||||
| { | { | ||||
| @@ -250,6 +246,10 @@ View: | |||||
| } | } | ||||
| } | } | ||||
| Template: | |||||
| {{#bold}}Hi {{name}}.{{/bold}} | |||||
| Output: | Output: | ||||
| <b>Hi Tater.</b> | <b>Hi Tater.</b> | ||||
| @@ -260,17 +260,17 @@ An inverted section opens with `{{^section}}` instead of `{{#section}}`. The | |||||
| block of an inverted section is rendered only if the value of that section's tag | block of an inverted section is rendered only if the value of that section's tag | ||||
| is `null`, `undefined`, `false`, or an empty list. | is `null`, `undefined`, `false`, or an empty list. | ||||
| Template: | |||||
| {{#repos}}<b>{{name}}</b>{{/repos}} | |||||
| {{^repos}}No repos :({{/repos}} | |||||
| View: | View: | ||||
| { | { | ||||
| "repos": [] | "repos": [] | ||||
| } | } | ||||
| Template: | |||||
| {{#repos}}<b>{{name}}</b>{{/repos}} | |||||
| {{^repos}}No repos :({{/repos}} | |||||
| Output: | Output: | ||||
| No repos :( | No repos :( | ||||