@@ -9,22 +9,78 @@ declare(strict_types=1);
99use Nette \Bridges \ApplicationLatte \UIMacros ;
1010use Tester \Assert ;
1111
12-
1312require __DIR__ . '/../bootstrap.php ' ;
1413
1514
16- $ compiler = new Latte \Compiler ;
17- UIMacros::install ($ compiler );
15+ $ latte = new Latte \Engine ;
16+ $ latte ->setLoader (new Latte \Loaders \StringLoader );
17+ UIMacros::install ($ latte ->getCompiler ());
1818
1919// {control ...}
20- Assert::match ('<?php %a% $this->global->uiControl->getComponent("form"); %a%->render(); ?> ' , $ compiler ->expandMacro ('control ' , 'form ' , '' )->openingCode );
21- @Assert::match ('<?php %a% $this->global->uiControl->getComponent("form"); %a%->render(); $ʟ_fi = new LR\FilterInfo( \'html \'); echo $this->filters->filterContent( \'filter \', $ʟ_fi, ob_get_clean()); ?> ' , $ compiler ->expandMacro ('control ' , 'form ' , 'filter ' )->openingCode ); // @deprecated
22- Assert::match ('<?php %a% if (is_object($form)) %a% else %a% $this->global->uiControl->getComponent($form); %a%->render(); ?> ' , $ compiler ->expandMacro ('control ' , '$form ' , '' )->openingCode );
23- Assert::match ('<?php %a% $this->global->uiControl->getComponent("form"); %a%->renderType(); ?> ' , $ compiler ->expandMacro ('control ' , 'form:type ' , '' )->openingCode );
24- Assert::match ('<?php %a% $this->global->uiControl->getComponent("form"); %a%->{"render$type"}(); ?> ' , $ compiler ->expandMacro ('control ' , 'form:$type ' , '' )->openingCode );
25- Assert::match ('<?php %a% $this->global->uiControl->getComponent("form"); %a%->renderType( \'param \'); ?> ' , $ compiler ->expandMacro ('control ' , 'form:type param ' , '' )->openingCode );
26- Assert::match ('<?php %a% $this->global->uiControl->getComponent("form"); %a%->render(array_merge([], $params, [])); ?> ' , $ compiler ->expandMacro ('control ' , 'form (expand) $params ' , '' )->openingCode );
27- Assert::match ('<?php %a% $this->global->uiControl->getComponent("form"); %a%->renderType([ \'param \' => 123]); ?> ' , $ compiler ->expandMacro ('control ' , 'form:type param => 123 ' , '' )->openingCode );
28- Assert::match ('<?php %a% $this->global->uiControl->getComponent("form"); %a%->renderType([ \'param \' => 123]); ?> ' , $ compiler ->expandMacro ('control ' , 'form:type, param => 123 ' , '' )->openingCode );
29- @Assert::match ('<?php %a% $this->global->uiControl->getComponent("form"); %a%->render(); $ʟ_fi = new LR\FilterInfo( \'html \'); echo $this->filters->filterContent( \'striptags \', $ʟ_fi, ob_get_clean()); ?> ' , $ compiler ->expandMacro ('control ' , 'form ' , 'striptags ' )->openingCode ); // @ deprecated
30- Assert::match ('<?php %a% $this->global->uiControl->getComponent("form"); %a%->renderType(param: 123); ?> ' , $ compiler ->expandMacro ('control ' , 'form:type, param: 123 ' , '' )->openingCode );
20+ Assert::match (
21+ '%A% $this->global->uiControl->getComponent("form");%A%->render();%A% ' ,
22+ $ latte ->compile ('{control form} ' )
23+ );
24+
25+ @Assert::match (
26+ <<<'XX'
27+ %A%
28+ /* line 1 */ $_tmp = $this->global->uiControl->getComponent("form");
29+ if ($_tmp instanceof Nette\Application\UI\Renderable) $_tmp->redrawControl(null, false);
30+ ob_start(function () {});
31+ $_tmp->render();
32+ $ʟ_fi = new LR\FilterInfo('html');
33+ echo $this->filters->filterContent('filter', $ʟ_fi, ob_get_clean());
34+ %A%
35+ XX
36+ ,
37+ $ latte ->compile ('{control form|filter} ' )
38+ ); // @deprecated
39+
40+ Assert::match (
41+ <<<'XX'
42+ %A%
43+ /* line 1 */ if (is_object($form)) $_tmp = $form;
44+ else $_tmp = $this->global->uiControl->getComponent($form);
45+ if ($_tmp instanceof Nette\Application\UI\Renderable) $_tmp->redrawControl(null, false);
46+ $_tmp->render();
47+ %A%
48+ XX
49+ ,
50+ $ latte ->compile ('{control $form} ' )
51+ );
52+
53+ Assert::match (
54+ '%A% $this->global->uiControl->getComponent("form");%A%->renderType();%A% ' ,
55+ $ latte ->compile ('{control form:type} ' )
56+ );
57+
58+ Assert::match (
59+ '%A% $this->global->uiControl->getComponent("form");%A%->{"render$type"}();%A% ' ,
60+ $ latte ->compile ('{control form:$type} ' )
61+ );
62+
63+ Assert::match (
64+ '%A% $this->global->uiControl->getComponent("form");%A%->renderType( \'param \');%A% ' ,
65+ $ latte ->compile ('{control form:type param} ' )
66+ );
67+
68+ Assert::match (
69+ '%A% $this->global->uiControl->getComponent("form");%A%->render(array_merge([], $params, []));%A% ' ,
70+ $ latte ->compile ('{control form (expand) $params} ' )
71+ );
72+
73+ Assert::match (
74+ '%A% $this->global->uiControl->getComponent("form");%A%->renderType([ \'param \' => 123]);%A% ' ,
75+ $ latte ->compile ('{control form:type param => 123} ' )
76+ );
77+
78+ Assert::match (
79+ '%A% $this->global->uiControl->getComponent("form");%A%->renderType([ \'param \' => 123]);%A% ' ,
80+ $ latte ->compile ('{control form:type, param => 123} ' )
81+ );
82+
83+ Assert::match (
84+ '%A% $this->global->uiControl->getComponent("form");%A%->renderType(param: 123);%A% ' ,
85+ $ latte ->compile ('{control form:type, param: 123} ' )
86+ );
0 commit comments