Обьекты в качесте значений
This commit is contained in:
parent
16fdce2f75
commit
a488b6085a
3 changed files with 58 additions and 7 deletions
|
|
@ -6,8 +6,7 @@ function title($x) {
|
|||
return ucfirst($x);
|
||||
}
|
||||
|
||||
$tpl = new Klein();
|
||||
$tpl->compile('tempalte.html');
|
||||
$tpl = new Klein('tempalte.html');
|
||||
|
||||
echo $tpl->render(array(
|
||||
'pagename' => 'awesome people',
|
||||
|
|
|
|||
30
examples/example4.php
Normal file
30
examples/example4.php
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
require_once '../klein.php';
|
||||
|
||||
function title($x) {
|
||||
return ucfirst($x);
|
||||
}
|
||||
|
||||
$tpl = new Klein('tempalte.html');
|
||||
|
||||
$u1 = new stdClass();
|
||||
$u1->name = 'Paul';
|
||||
$u1->age = 10;
|
||||
|
||||
$u2 = new stdClass();
|
||||
$u2->name = 'Jim';
|
||||
$u2->age = 11;
|
||||
|
||||
$u3 = new stdClass();
|
||||
$u3->name = 'Jane';
|
||||
$u3->age = 12;
|
||||
|
||||
echo $tpl->render(array(
|
||||
'pagename' => 'awesome people',
|
||||
'authors' => [$u1, $u2, $u3],
|
||||
'city'=> [
|
||||
'Yaroslaval' => 1,
|
||||
'Moscow' => 2
|
||||
]
|
||||
));
|
||||
Loading…
Add table
Add a link
Reference in a new issue