Примеры в отдельную папку
This commit is contained in:
parent
0f62ba3a29
commit
313413931b
7 changed files with 6 additions and 6 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once 'klein.php';
|
require_once '../klein.php';
|
||||||
|
|
||||||
function title($x) {
|
function title($x) {
|
||||||
return ucfirst($x);
|
return ucfirst($x);
|
||||||
|
|
@ -27,7 +27,7 @@ $data = array (
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
require_once 'klein.php';
|
require_once '../klein.php';
|
||||||
|
|
||||||
$tpl = new Klein();
|
$tpl = new Klein();
|
||||||
$tpl->compile('template2.html');
|
$tpl->compile('template2.html');
|
||||||
|
|
@ -2,8 +2,7 @@
|
||||||
|
|
||||||
$data = array('phedor', 'andrey');
|
$data = array('phedor', 'andrey');
|
||||||
|
|
||||||
|
require_once '../klein.php';
|
||||||
require_once 'klein.php';
|
|
||||||
|
|
||||||
$tpl = new Klein();
|
$tpl = new Klein();
|
||||||
$tpl->compile('template3.html');
|
$tpl->compile('template3.html');
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
<div>
|
|
||||||
{% macro hello(name) %}
|
{% macro hello(name) %}
|
||||||
<em>hello, {{ name }} {{! name }}<em>
|
<em>hello, {{ name }} {{! name }}<em>
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|
||||||
|
<div>
|
||||||
{% for name in names %}
|
{% for name in names %}
|
||||||
{{ hello(name) }}
|
{{ hello(name) }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
@ -11,7 +11,8 @@ class Klein {
|
||||||
function ($x) use ($result) {
|
function ($x) use ($result) {
|
||||||
$code = "<?php " . preg_replace_callback("/#(\d+)(s?)/", function ($s) use($x) {
|
$code = "<?php " . preg_replace_callback("/#(\d+)(s?)/", function ($s) use($x) {
|
||||||
$pref = $s[2] == 's' ? '$' : '';
|
$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) . " ?>";
|
}, $result) . " ?>";
|
||||||
return ($x[0][2] == '!') ? "<!-- $code -->" : $code;
|
return ($x[0][2] == '!') ? "<!-- $code -->" : $code;
|
||||||
}];
|
}];
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue