Поменял местам key value
This commit is contained in:
parent
7562f54d2c
commit
3f5d4a5e9c
5 changed files with 46 additions and 4 deletions
|
|
@ -7,7 +7,7 @@ function title($x) {
|
|||
}
|
||||
|
||||
$tpl = new Klein();
|
||||
$tpl->compile('index.html');
|
||||
$tpl->compile('tempalte.html');
|
||||
|
||||
echo $tpl->render(array(
|
||||
'pagename' => 'awesome people',
|
||||
|
|
|
|||
35
example2.php
Normal file
35
example2.php
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
$data = array (
|
||||
array (
|
||||
'id' => 0,
|
||||
'id_table' => 0,
|
||||
'name' => '',
|
||||
'header' => 'Наименование муниципального образования',
|
||||
'comment' => '',
|
||||
'colspan' => 0,
|
||||
'rowspan' => 4,
|
||||
'row' => 0,
|
||||
'position' => 0,
|
||||
'type' => '',
|
||||
),
|
||||
array (
|
||||
'id' => 1,
|
||||
'id_table' => 0,
|
||||
'name' => '',
|
||||
'header' => '',
|
||||
'comment' => 'Над строкой - Прибыло всего (взрослых и детей)',
|
||||
'rowspan' => 0,
|
||||
'row' => 0,
|
||||
'position' => 1,
|
||||
'type' => '',
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
require_once 'klein.php';
|
||||
|
||||
$tpl = new Klein();
|
||||
$tpl->compile('template2.html');
|
||||
|
||||
echo $tpl->render(array('content' => $data));
|
||||
|
|
@ -15,7 +15,7 @@ class Klein {
|
|||
}];
|
||||
}, [
|
||||
["{% 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):"],
|
||||
["{% for+:id , :id+in+:var %}", "foreach(\$#3 as \$#1 => \$#2):"],
|
||||
["{% endfor %}", "endforeach;"],
|
||||
["{% if+:var %}", "if(isset(\$#1) && \$#1 ):"],
|
||||
["{% endif %}", "endif;"],
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@
|
|||
|
||||
{% for key, value in city %}
|
||||
<li>
|
||||
<div class="name">{{ value }}</div>
|
||||
<div class="age">{{ key }}</div>
|
||||
<div class="value">{{ value }}</div>
|
||||
<div class="key">{{ key }}</div>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
7
template2.html
Normal file
7
template2.html
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<div>
|
||||
{% for var in content %}
|
||||
{% for key, value in var %}
|
||||
{{key}} - {{value}}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
Loading…
Add table
Add a link
Reference in a new issue