Exemplo n.º 1
0
 public function testFromString()
 {
     $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();
     $expected = "\nBefore first bloc testVal1\n\n\n\n    first bloc start testFirst1\n\n    \n        content of second bloc with testSecond\n        \n            content of 5th bloc with test4th\n        \n            content of 5th bloc with test5th\n        \n    \n\n    first bloc middle testFirst3\n\n    \n        content of third bloc with testThird1\n    \n        content of third bloc with testThird2\n    \n\n    \n\n    first bloc end testFirst3\n\n\nAfter first bloc testVal1\n";
     $this->assertEquals($expected, $result);
 }
Exemplo n.º 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;