Цыкл с ключом
This commit is contained in:
parent
a49f10601b
commit
7562f54d2c
3 changed files with 14 additions and 1 deletions
|
|
@ -11,5 +11,9 @@ $tpl->compile('index.html');
|
||||||
|
|
||||||
echo $tpl->render(array(
|
echo $tpl->render(array(
|
||||||
'pagename' => 'awesome people',
|
'pagename' => 'awesome people',
|
||||||
'authors' => [['name' => 'Paul', 'age' => 10], ['name' => 'Jim', 'age' => 11], ['name' => 'Jane', 'age' => 12]]
|
'authors' => [['name' => 'Paul', 'age' => 10], ['name' => 'Jim', 'age' => 11], ['name' => 'Jane', 'age' => 12]],
|
||||||
|
'city'=> [
|
||||||
|
'Yaroslaval' => 1,
|
||||||
|
'Moscow' => 2
|
||||||
|
]
|
||||||
));
|
));
|
||||||
|
|
@ -7,4 +7,12 @@
|
||||||
<div class="age">{{ author.age }}</div>
|
<div class="age">{{ author.age }}</div>
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
|
||||||
|
{% for key, value in city %}
|
||||||
|
<li>
|
||||||
|
<div class="name">{{ value }}</div>
|
||||||
|
<div class="age">{{ key }}</div>
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
@ -15,6 +15,7 @@ class Klein {
|
||||||
}];
|
}];
|
||||||
}, [
|
}, [
|
||||||
["{% for+:id+in+:var %}", "foreach(\$#2 as \$index => \$#1): \$loop = ['first' => \$index == 0, 'last' => \$index == count(\$#2) - 1];"],
|
["{% for+:id+in+:var %}", "foreach(\$#2 as \$index => \$#1): \$loop = ['first' => \$index == 0, 'last' => \$index == count(\$#2) - 1];"],
|
||||||
|
["{% for+:id , :id+in+:var %}", "foreach(\$#3 as \$#2 => \$#1):"],
|
||||||
["{% endfor %}", "endforeach;"],
|
["{% endfor %}", "endforeach;"],
|
||||||
["{% if+:var %}", "if(isset(\$#1) && \$#1 ):"],
|
["{% if+:var %}", "if(isset(\$#1) && \$#1 ):"],
|
||||||
["{% endif %}", "endif;"],
|
["{% endif %}", "endif;"],
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue