-
Notifications
You must be signed in to change notification settings - Fork 0
Loop
Ilya edited this page Jan 18, 2017
·
1 revision
Loops? No, problem
Let's imagine that we need a loop
// data
let loop = [
{ firstname : 'Ilya',
lastname : 'Chubarov'
},
{
firstname : 'Maria',
lastname : 'Ivanova'
},
{
firstname : 'Misha',
lastname : 'Bootosov',
age : 20
},
{
firstname : 'Misha',
lastname : 'Bootosov',
age : 20 ,
child : {
name : 'To'
}
}
];
// index.html
<div id="test">
<div class="entry">
<ul>
{{#each loop}}
<li>
<p>firstname : {{ firstname }}</p>
<p>lastname {{ lastname }}<p>
{{#if age}}
<h1>{{ age }}</h1>
{{#else}}
<p>it is unknown how many years</p>
{{/if}}
{{#if child}}
<h1>{{ child.name }}</h1>
{{/if}}
</li>
{{/each}}
</ul>
</div>
</div>