Примеры в отдельную папку

This commit is contained in:
Федор Подлеснов 2015-12-11 12:14:30 +03:00
parent 0f62ba3a29
commit 313413931b
7 changed files with 6 additions and 6 deletions

View file

@ -1,6 +1,6 @@
<?php
require_once 'klein.php';
require_once '../klein.php';
function title($x) {
return ucfirst($x);

View file

@ -27,7 +27,7 @@ $data = array (
);
require_once 'klein.php';
require_once '../klein.php';
$tpl = new Klein();
$tpl->compile('template2.html');

View file

@ -2,8 +2,7 @@
$data = array('phedor', 'andrey');
require_once 'klein.php';
require_once '../klein.php';
$tpl = new Klein();
$tpl->compile('template3.html');

View file

@ -1,8 +1,8 @@
<div>
{% macro hello(name) %}
<em>hello, {{ name }} {{! name }}<em>
{% endmacro %}
<div>
{% for name in names %}
{{ hello(name) }}
{% endfor %}

View file

@ -11,7 +11,8 @@ class Klein {
function ($x) use ($result) {
$code = "<?php " . preg_replace_callback("/#(\d+)(s?)/", function ($s) use($x) {
$pref = $s[2] == 's' ? '$' : '';
return implode(", ", array_map(function ($s) use($pref) { return $pref.preg_replace("/\.\s*(\w+)/", "['$1']", $s); }, preg_split("/\s*,\s*/", $x[$s[1]])));
return implode(", ", array_map(function ($s) use($pref) {
return $pref.preg_replace("/\.\s*(\w+)/", "['$1']", $s); }, preg_split("/\s*,\s*/", $x[$s[1]])));
}, $result) . " ?>";
return ($x[0][2] == '!') ? "<!-- $code -->" : $code;
}];