From 7562f54d2c5841fdbd6ad6d1af5d258894214ca2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A4=D0=B5=D0=B4=D0=BE=D1=80=20=D0=9F=D0=BE=D0=B4=D0=BB?= =?UTF-8?q?=D0=B5=D1=81=D0=BD=D0=BE=D0=B2?= Date: Thu, 3 Dec 2015 10:14:09 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A6=D1=8B=D0=BA=D0=BB=20=D1=81=20=D0=BA?= =?UTF-8?q?=D0=BB=D1=8E=D1=87=D0=BE=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example.php | 6 +++++- index.html | 8 ++++++++ klein.php | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/example.php b/example.php index 19d442c..63ec049 100644 --- a/example.php +++ b/example.php @@ -11,5 +11,9 @@ $tpl->compile('index.html'); echo $tpl->render(array( '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 + ] )); \ No newline at end of file diff --git a/index.html b/index.html index 8270d6c..a9b2e21 100644 --- a/index.html +++ b/index.html @@ -7,4 +7,12 @@
{{ author.age }}
{% endfor %} + + +{% for key, value in city %} +
  • +
    {{ value }}
    +
    {{ key }}
    +
  • +{% endfor %} \ No newline at end of file diff --git a/klein.php b/klein.php index 99a43cb..2bacd1e 100644 --- a/klein.php +++ b/klein.php @@ -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 , :id+in+:var %}", "foreach(\$#3 as \$#2 => \$#1):"], ["{% endfor %}", "endforeach;"], ["{% if+:var %}", "if(isset(\$#1) && \$#1 ):"], ["{% endif %}", "endif;"],