Пример #1
0
 public function testImport()
 {
     \Bixev\LightHtmlTemplate\Factory::addDirectory(__DIR__ . DIRECTORY_SEPARATOR . 'html');
     $tpl = \Bixev\LightHtmlTemplate\Factory::newTemplateFromFile('test2');
     $tpl->pB(['firstBloc' => [], 'test3FirstBLoc' => []]);
     $result = $tpl->render();
     $expected = "tutu2\n\ntest first bloc\n\n\ntutu3\n\ntest3FirstBloc content\n\n\ntutu4\n\n\n";
     $this->assertEquals($expected, $result);
 }
Пример #2
0
<?php

$template = "\nBefore first bloc {{var1 | unknownFunction}}\n{{ unknownVar }}{{unknownVar | unknownFunction}}\n{{bloc:myFirstBloc}}\n\n    first bloc start {{var1}}\n\n    {{bloc:mySecondBloc}}\n        content of second bloc with {{var}}\n        {{bloc:my5thBloc}}\n            content of 5th bloc with {{ var }}\n        {{endbloc:my5thBloc}}\n    {{endbloc:mySecondBloc}}\n\n    first bloc middle {{var3 }}\n\n    {{ bloc:myThirdBloc }}\n        content of third bloc with {{var}}\n    {{endbloc:myThirdBloc}}\n\n    {{bloc:my4thBloc}}\n        content of 4th bloc with {{var}}\n    {{ endbloc:my4thBloc }}\n\n    first bloc end {{ var3}}\n\n{{endbloc:myFirstBloc}}\nAfter first bloc {{var1}}\n";
$tpl = \Bixev\LightHtmlTemplate\Factory::newTemplateFromString($template);
$tpl->pB(['var1' => 'testVal1', 'myFirstBloc' => ['var1' => 'testFirst1', 'var2' => 'testFirst2', 'var3' => 'testFirst3', 'mySecondBloc' => ['var' => 'testSecond', 'my5thBloc' => [['var' => 'test4th'], ['var' => 'test5th']]], 'myThirdBloc' => [['var' => 'testThird1'], ['var' => 'testThird2']]]]);
$result = $tpl->render();
echo $result;