feat: Поддержка psr4. Кеширование шаблона
This commit is contained in:
parent
825641813b
commit
0c30dc230d
9 changed files with 71 additions and 61 deletions
|
|
@ -1,14 +1,16 @@
|
|||
<?php
|
||||
|
||||
require_once '../Klein.php';
|
||||
require_once '../src/Klein.php';
|
||||
|
||||
use ctiso\Klein;
|
||||
|
||||
function title($x) {
|
||||
return ucfirst($x);
|
||||
}
|
||||
|
||||
$tpl = new Klein('tempalte.html');
|
||||
$tpl = new Klein(__DIR__ . '/cache');
|
||||
|
||||
echo $tpl->render([
|
||||
echo $tpl->render('template.html', [
|
||||
'pagename' => 'awesome people',
|
||||
'authors' => [['name' => 'Paul', 'age' => 10], ['name' => 'Jim', 'age' => 11], ['name' => 'Jane', 'age' => 12]],
|
||||
'city'=> [
|
||||
|
|
|
|||
|
|
@ -1,34 +1,34 @@
|
|||
<?php
|
||||
|
||||
require_once '../Klein.php';
|
||||
use ctiso\Klein;
|
||||
|
||||
$data = [
|
||||
[
|
||||
'id' => 0,
|
||||
'id_table' => 0,
|
||||
'name' => '',
|
||||
'header' => 'Наименование муниципального образования',
|
||||
'comment' => '',
|
||||
'colspan' => 0,
|
||||
'rowspan' => 4,
|
||||
'row' => 0,
|
||||
'position' => 0,
|
||||
'type' => '',
|
||||
],
|
||||
[
|
||||
'id' => 1,
|
||||
'id_table' => 0,
|
||||
[
|
||||
'id' => 0,
|
||||
'id_table' => 0,
|
||||
'name' => '',
|
||||
'header' => '',
|
||||
'comment' => 'Над строкой - Прибыло всего (взрослых и детей)',
|
||||
'rowspan' => 0,
|
||||
'row' => 0,
|
||||
'position' => 1,
|
||||
'type' => '',
|
||||
'header' => 'Header #1',
|
||||
'comment' => '',
|
||||
'colspan' => 0,
|
||||
'rowspan' => 4,
|
||||
'row' => 0,
|
||||
'position' => 0,
|
||||
'type' => '',
|
||||
],
|
||||
[
|
||||
'id' => 1,
|
||||
'id_table' => 0,
|
||||
'name' => '',
|
||||
'header' => '',
|
||||
'comment' => 'Header #2',
|
||||
'rowspan' => 0,
|
||||
'row' => 0,
|
||||
'position' => 1,
|
||||
'type' => '',
|
||||
]
|
||||
];
|
||||
|
||||
|
||||
require_once '../Klein.php';
|
||||
|
||||
$tpl = new Klein('template2.html');
|
||||
|
||||
echo $tpl->render(['content' => $data]);
|
||||
$tpl = new Klein(__DIR__ . '/cache');
|
||||
echo $tpl->render('template2.html'. ['content' => $data]);
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
<?php
|
||||
|
||||
require_once '../Klein.php';
|
||||
use ctiso\Klein;
|
||||
|
||||
$data = ['phedor', 'andrey'];
|
||||
|
||||
require_once '../Klein.php';
|
||||
$tpl = new Klein(__DIR__ . '/cache');
|
||||
|
||||
$tpl = new Klein('template3.html');
|
||||
|
||||
echo $tpl->render(['names' => $data]);
|
||||
echo $tpl->render('template3.html', ['names' => $data]);
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
<?php
|
||||
|
||||
require_once '../Klein.php';
|
||||
use ctiso\Klein;
|
||||
|
||||
function title($x) {
|
||||
return ucfirst($x);
|
||||
}
|
||||
|
||||
$tpl = new Klein('template.html');
|
||||
$tpl = new Klein(__DIR__ . '/cache');
|
||||
|
||||
$u1 = new stdClass();
|
||||
$u1->name = 'Paul';
|
||||
|
|
@ -20,7 +21,7 @@ $u3 = new stdClass();
|
|||
$u3->name = 'Jane';
|
||||
$u3->age = 12;
|
||||
|
||||
echo $tpl->render([
|
||||
echo $tpl->render('template.html', [
|
||||
'pagename' => 'awesome people',
|
||||
'authors' => [$u1, $u2, $u3],
|
||||
'city'=> [
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<div>
|
||||
{% for var in content %}
|
||||
{% for key, value in var %}
|
||||
<b>{{key}} - {{value}}</b>
|
||||
<b>{{ key }} - {{ value }}</b>
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
Loading…
Add table
Add a link
Reference in a new issue