|
|
|
@@ -93,7 +93,7 @@ enumeration section. |
|
|
|
If a section key returns a function, it will be called and passed both the |
|
|
|
unrendered block of text and a renderer convenience function. |
|
|
|
|
|
|
|
Given this JS: |
|
|
|
Given this object: |
|
|
|
|
|
|
|
"name": "Tater", |
|
|
|
"bolder": function() { |
|
|
|
@@ -115,39 +115,36 @@ to implement caching, filters (like syntax highlighting), etc. |
|
|
|
|
|
|
|
You can use `this.name` to access the attribute `name` from your view. |
|
|
|
|
|
|
|
### Dereferencing Section |
|
|
|
### Dereferencing Sections |
|
|
|
|
|
|
|
If you have a nested object structure in your view, it can sometimes be easier |
|
|
|
to use sections like this: |
|
|
|
If your data has components that are logically grouped into nested objects, |
|
|
|
you may wish to dereference an object to access its values. |
|
|
|
|
|
|
|
var objects = { |
|
|
|
a_object: { |
|
|
|
title: 'this is an object', |
|
|
|
description: 'one of its attributes is a list', |
|
|
|
a_list: [{label: 'listitem1'}, {label: 'listitem2'}] |
|
|
|
Given this object: |
|
|
|
|
|
|
|
{ |
|
|
|
"name": "Bill", |
|
|
|
"address": { |
|
|
|
"street": "801 Streetly street", |
|
|
|
"city": "Boston", |
|
|
|
"state": "MA", |
|
|
|
"zip" "02101" |
|
|
|
} |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
And this template: |
|
|
|
|
|
|
|
<h1>Contact: {{name}}</h1> |
|
|
|
{{#address}} |
|
|
|
<p>{{street}}</p> |
|
|
|
<p>{{city}}, {{state}} {{zip}}</p> |
|
|
|
{{/address}} |
|
|
|
|
|
|
|
We'll get this output: |
|
|
|
|
|
|
|
This is our template: |
|
|
|
|
|
|
|
{{#a_object}} |
|
|
|
<h1>{{title}}</h1> |
|
|
|
<p>{{description}}</p> |
|
|
|
<ul> |
|
|
|
{{#a_list}} |
|
|
|
<li>{{label}}</li> |
|
|
|
{{/a_list}} |
|
|
|
</ul> |
|
|
|
{{/a_object}} |
|
|
|
|
|
|
|
Here is the result: |
|
|
|
|
|
|
|
<h1>this is an object</h1> |
|
|
|
<p>one of its attributes is a list</p> |
|
|
|
<ul> |
|
|
|
<li>listitem1</li> |
|
|
|
<li>listitem2</li> |
|
|
|
</ul> |
|
|
|
<h1>Contact: Bill</h1> |
|
|
|
<p>801 Streetly street</p> |
|
|
|
<p>Boston, MA 02101</p> |
|
|
|
|
|
|
|
### Inverted Sections |
|
|
|
|
|
|
|
|