diff --git a/src/Bridges/FormsLatte/FormsExtension.php b/src/Bridges/FormsLatte/FormsExtension.php index 3e13a0b88..92dd0b20d 100644 --- a/src/Bridges/FormsLatte/FormsExtension.php +++ b/src/Bridges/FormsLatte/FormsExtension.php @@ -38,7 +38,13 @@ public function getTags(): array public function getProviders(): array { return [ - 'formsStack' => [], + 'forms' => new Runtime, ]; } + + + public function getCacheKey(Latte\Engine $engine): array + { + return ['version' => 2]; + } } diff --git a/src/Bridges/FormsLatte/Nodes/FieldNNameNode.php b/src/Bridges/FormsLatte/Nodes/FieldNNameNode.php index 78ce293a6..bbf3681ea 100644 --- a/src/Bridges/FormsLatte/Nodes/FieldNNameNode.php +++ b/src/Bridges/FormsLatte/Nodes/FieldNNameNode.php @@ -64,7 +64,7 @@ private function init(Tag $tag) $elName = strtolower($el->name); $tag->replaceNAttribute(new AuxiliaryNode(fn(PrintContext $context) => $context->format( - 'echo ($ʟ_input = Nette\Bridges\FormsLatte\Runtime::item(%node, $this->global))' + 'echo ($ʟ_input = $this->global->forms->item(%node))' . ($elName === 'label' ? '->getLabelPart(%node)' : '->getControlPart(%node)') . ($usedAttributes ? '->addAttributes(%dump)' : '') . '->attributes() %3.line;', diff --git a/src/Bridges/FormsLatte/Nodes/FormContainerNode.php b/src/Bridges/FormsLatte/Nodes/FormContainerNode.php index 36cd2aa9f..9569d8a85 100644 --- a/src/Bridges/FormsLatte/Nodes/FormContainerNode.php +++ b/src/Bridges/FormsLatte/Nodes/FormContainerNode.php @@ -41,9 +41,9 @@ public static function create(Tag $tag): \Generator public function print(PrintContext $context): string { return $context->format( - '$this->global->formsStack[] = $formContainer = Nette\Bridges\FormsLatte\Runtime::item(%node, $this->global) %line; ' + '$this->global->forms->begin($formContainer = $this->global->forms->item(%node)) %line; ' . '%node ' - . 'array_pop($this->global->formsStack); $formContainer = end($this->global->formsStack);' + . '$this->global->forms->end(); $formContainer = $this->global->forms->current();' . "\n\n", $this->name, $this->position, diff --git a/src/Bridges/FormsLatte/Nodes/FormNNameNode.php b/src/Bridges/FormsLatte/Nodes/FormNNameNode.php index 75119298e..b46ceb866 100644 --- a/src/Bridges/FormsLatte/Nodes/FormNNameNode.php +++ b/src/Bridges/FormsLatte/Nodes/FormNNameNode.php @@ -42,14 +42,13 @@ public static function create(Tag $tag): \Generator public function print(PrintContext $context): string { return $context->format( - '$form = $this->global->formsStack[] = ' + '$this->global->forms->begin($form = ' . ($this->name instanceof StringNode ? '$this->global->uiControl[%node]' - : 'is_object($ʟ_tmp = %node) ? $ʟ_tmp : $this->global->uiControl[$ʟ_tmp]') - . ' %line;' - . 'Nette\Bridges\FormsLatte\Runtime::initializeForm($form);' + : '(is_object($ʟ_tmp = %node) ? $ʟ_tmp : $this->global->uiControl[$ʟ_tmp])') + . ') %line;' . '%node ' - . 'array_pop($this->global->formsStack);', + . '$this->global->forms->end();', $this->name, $this->position, $this->content, @@ -62,7 +61,7 @@ private function init(Tag $tag) $el = $tag->htmlElement; $tag->replaceNAttribute(new AuxiliaryNode(fn(PrintContext $context) => $context->format( - 'echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin(end($this->global->formsStack), %dump, false) %line;', + 'echo $this->global->forms->renderFormBegin(%dump, false) %line;', array_fill_keys(FieldNNameNode::findUsedAttributes($el), null), $this->position, ))); @@ -70,7 +69,7 @@ private function init(Tag $tag) $el->content = new Latte\Compiler\Nodes\FragmentNode([ $el->content, new AuxiliaryNode(fn(PrintContext $context) => $context->format( - 'echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(end($this->global->formsStack), false) %line;', + 'echo $this->global->forms->renderFormEnd(false) %line;', $this->position, )), ]); diff --git a/src/Bridges/FormsLatte/Nodes/FormNode.php b/src/Bridges/FormsLatte/Nodes/FormNode.php index 2146a18a3..b98d6e3f9 100644 --- a/src/Bridges/FormsLatte/Nodes/FormNode.php +++ b/src/Bridges/FormsLatte/Nodes/FormNode.php @@ -61,20 +61,21 @@ public static function create(Tag $tag): \Generator public function print(PrintContext $context): string { return $context->format( - '$form = $this->global->formsStack[] = ' + '$this->global->forms->begin($form = ' . ($this->name instanceof StringNode ? '$this->global->uiControl[%node]' - : 'is_object($ʟ_tmp = %node) ? $ʟ_tmp : $this->global->uiControl[$ʟ_tmp]') - . ' %line;' - . 'Nette\Bridges\FormsLatte\Runtime::initializeForm($form);' + : '(is_object($ʟ_tmp = %node) ? $ʟ_tmp : $this->global->uiControl[$ʟ_tmp])') + . ') %line;' . ($this->print - ? 'echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form, %node) %1.line;' + ? 'echo $this->global->forms->renderFormBegin(%node) %1.line;' : '') . ' %3.node ' . ($this->print - ? 'echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(array_pop($this->global->formsStack))' - : 'array_pop($this->global->formsStack)') - . " %4.line;\n\n", + ? 'echo $this->global->forms->renderFormEnd()' + : '') + . ' %4.line;' + . '$this->global->forms->end();' + . "\n\n", $this->name, $this->position, $this->attributes, diff --git a/src/Bridges/FormsLatte/Nodes/FormPrintNode.php b/src/Bridges/FormsLatte/Nodes/FormPrintNode.php index 427beedbb..eb25d4b2c 100644 --- a/src/Bridges/FormsLatte/Nodes/FormPrintNode.php +++ b/src/Bridges/FormsLatte/Nodes/FormPrintNode.php @@ -39,10 +39,10 @@ public static function create(Tag $tag): static public function print(PrintContext $context): string { return $context->format( - 'Nette\Bridges\FormsLatte\Runtime::render%raw(' + '$this->global->forms->render%raw(' . ($this->name ? 'is_object($ʟ_tmp = %node) ? $ʟ_tmp : $this->global->uiControl[$ʟ_tmp]' - : 'end($this->global->formsStack)') + : '$this->global->forms->current()') . ') %2.line; exit;', $this->mode, $this->name, diff --git a/src/Bridges/FormsLatte/Nodes/InputErrorNode.php b/src/Bridges/FormsLatte/Nodes/InputErrorNode.php index 014e16d69..c30a6bba4 100644 --- a/src/Bridges/FormsLatte/Nodes/InputErrorNode.php +++ b/src/Bridges/FormsLatte/Nodes/InputErrorNode.php @@ -37,7 +37,7 @@ public static function create(Tag $tag): static public function print(PrintContext $context): string { return $context->format( - 'echo %escape(Nette\Bridges\FormsLatte\Runtime::item(%node, $this->global)->getError()) %line;', + 'echo %escape($this->global->forms->item(%node)->getError()) %line;', $this->name, $this->position, ); diff --git a/src/Bridges/FormsLatte/Nodes/InputNode.php b/src/Bridges/FormsLatte/Nodes/InputNode.php index d9f6841eb..be5a4e3b8 100644 --- a/src/Bridges/FormsLatte/Nodes/InputNode.php +++ b/src/Bridges/FormsLatte/Nodes/InputNode.php @@ -48,7 +48,7 @@ public static function create(Tag $tag): static public function print(PrintContext $context): string { return $context->format( - 'echo Nette\Bridges\FormsLatte\Runtime::item(%node, $this->global)->' + 'echo $this->global->forms->item(%node)->' . ($this->part ? ('getControlPart(%node)') : 'getControl()') . ($this->attributes->items ? '->addAttributes(%2.node)' : '') . ' %3.line;', diff --git a/src/Bridges/FormsLatte/Nodes/LabelNode.php b/src/Bridges/FormsLatte/Nodes/LabelNode.php index cf1316c59..82990d9e0 100644 --- a/src/Bridges/FormsLatte/Nodes/LabelNode.php +++ b/src/Bridges/FormsLatte/Nodes/LabelNode.php @@ -63,7 +63,7 @@ public static function create(Tag $tag): \Generator public function print(PrintContext $context): string { return $context->format( - 'echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item(%node, $this->global)->' + 'echo ($ʟ_label = $this->global->forms->item(%node)->' . ($this->part ? 'getLabelPart(%node)' : 'getLabel()') . ')' . ($this->attributes->items ? '?->addAttributes(%2.node)' : '') diff --git a/src/Bridges/FormsLatte/Runtime.php b/src/Bridges/FormsLatte/Runtime.php index b9979c899..b1c91f584 100644 --- a/src/Bridges/FormsLatte/Runtime.php +++ b/src/Bridges/FormsLatte/Runtime.php @@ -11,6 +11,7 @@ use Latte; use Nette; +use Nette\Forms\Container; use Nette\Forms\Form; use Nette\Utils\Html; @@ -21,22 +22,16 @@ */ class Runtime { - use Nette\StaticClass; - - public static function initializeForm(Form $form): void - { - $form->fireRenderEvents(); - foreach ($form->getControls() as $control) { - $control->setOption('rendered', false); - } - } + /** @var Container[] */ + private array $stack = []; /** * Renders form begin. */ - public static function renderFormBegin(Form $form, array $attrs, bool $withTags = true): string + public function renderFormBegin(array $attrs, bool $withTags = true): string { + $form = $this->current(); $el = $form->getElementPrototype(); $el->action = (string) $el->action; $el = clone $el; @@ -52,8 +47,9 @@ public static function renderFormBegin(Form $form, array $attrs, bool $withTags /** * Renders form end. */ - public static function renderFormEnd(Form $form, bool $withTags = true): string + public function renderFormEnd(bool $withTags = true): string { + $form = $this->current(); $s = ''; if ($form->isMethod('get')) { foreach (preg_split('#[;&]#', (string) parse_url($form->getElementPrototype()->action, PHP_URL_QUERY), -1, PREG_SPLIT_NO_EMPTY) as $param) { @@ -79,7 +75,7 @@ public static function renderFormEnd(Form $form, bool $withTags = true): string /** * Generates blueprint of form. */ - public static function renderFormPrint(Form $form): void + public function renderFormPrint(Form $form): void { $blueprint = class_exists(Latte\Runtime\Blueprint::class) ? new Latte\Runtime\Blueprint @@ -94,7 +90,7 @@ public static function renderFormPrint(Form $form): void /** * Generates blueprint of form data class. */ - public static function renderFormClassPrint(Form $form): void + public function renderFormClassPrint(Form $form): void { $blueprint = class_exists(Latte\Runtime\Blueprint::class) ? new Latte\Runtime\Blueprint @@ -110,12 +106,35 @@ public static function renderFormClassPrint(Form $form): void } - public static function item($item, $global): object + public function item($item): object { - if (is_object($item)) { - return $item; + return is_object($item) + ? $item + : $this->current()[$item]; + } + + + public function begin(Container $form): void + { + $this->stack[] = $form; + + if ($form instanceof Form) { + $form->fireRenderEvents(); + foreach ($form->getControls() as $control) { + $control->setOption('rendered', false); + } } - $form = end($global->formsStack) ?: throw new \LogicException('Form declaration is missing, did you use {form} or
tag?'); - return $form[$item]; + } + + + public function end(): void + { + array_pop($this->stack); + } + + + public function current(): Container + { + return end($this->stack) ?: throw new \LogicException('Form declaration is missing, did you use {form} or tag?'); } } diff --git a/tests/Forms.Latte3/Runtime.get.phpt b/tests/Forms.Latte3/Runtime.get.phpt index 976bd4a15..243013172 100644 --- a/tests/Forms.Latte3/Runtime.get.phpt +++ b/tests/Forms.Latte3/Runtime.get.phpt @@ -15,12 +15,15 @@ $form->addText('arg1'); $form->addText('arg2'); $form->setAction('http://example.com/?do=foo-submit&arg0=1&arg1=1&arg2[x]=1#toc'); +$runtime = new Runtime; +$runtime->begin($form); + Assert::same( '', - Runtime::renderFormBegin($form, []), + $runtime->renderFormBegin([]), ); Assert::match( '
', - Runtime::renderFormEnd($form), + $runtime->renderFormEnd(), ); diff --git a/tests/Forms.Latte3/Runtime.renderFormClassPrint.phpt b/tests/Forms.Latte3/Runtime.renderFormClassPrint.phpt index 4a0b3df07..197003ba6 100644 --- a/tests/Forms.Latte3/Runtime.renderFormClassPrint.phpt +++ b/tests/Forms.Latte3/Runtime.renderFormClassPrint.phpt @@ -12,7 +12,7 @@ $form = new Form('signForm'); $form->addText('name')->setRequired(); ob_start(); -Nette\Bridges\FormsLatte\Runtime::renderFormClassPrint($form); +(new Nette\Bridges\FormsLatte\Runtime)->renderFormClassPrint($form); $res = ob_get_clean(); Assert::match( diff --git a/tests/Forms.Latte3/Runtime.renderFormPrint.phpt b/tests/Forms.Latte3/Runtime.renderFormPrint.phpt index 36fe1b427..6616e36dc 100644 --- a/tests/Forms.Latte3/Runtime.renderFormPrint.phpt +++ b/tests/Forms.Latte3/Runtime.renderFormPrint.phpt @@ -14,7 +14,7 @@ $form->addText('name')->setRequired('Enter your name'); $form->addSubmit('submit', 'Send'); ob_start(); -Nette\Bridges\FormsLatte\Runtime::renderFormPrint($form); +(new Nette\Bridges\FormsLatte\Runtime)->renderFormPrint($form); $res = ob_get_clean(); Assert::match( diff --git a/tests/Forms.Latte3/expected/forms.button.php b/tests/Forms.Latte3/expected/forms.button.php index 39b37e7dd..8af2b21b2 100644 --- a/tests/Forms.Latte3/expected/forms.button.php +++ b/tests/Forms.Latte3/expected/forms.button.php @@ -1,28 +1,27 @@ global->formsStack[] = $this->global->uiControl['myForm'] /* line %d% */; - Nette\Bridges\FormsLatte\Runtime::initializeForm($form); + $this->global->forms->begin($form = $this->global->uiControl['myForm']) /* line %d% */; echo 'global->formsStack), [], false) /* line %d% */; + echo $this->global->forms->renderFormBegin([], false) /* line %d% */; echo '> global))->getControlPart()->attributes() /* line %d% */; + echo ($ʟ_input = $this->global->forms->item('send'))->getControlPart()->attributes() /* line %d% */; echo '> description of button global))->getControlPart()->attributes() /* line %d% */; + echo ($ʟ_input = $this->global->forms->item('send'))->getControlPart()->attributes() /* line %d% */; echo '> global))->getControlPart()->attributes() /* line %d% */; + echo ($ʟ_input = $this->global->forms->item('send'))->getControlPart()->attributes() /* line %d% */; echo '>'; echo LR\Filters::escapeHtmlText($ʟ_input->getCaption()) /* line %d% */; echo ' '; - echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(end($this->global->formsStack), false) /* line %d% */; + echo $this->global->forms->renderFormEnd(false) /* line %d% */; echo ' '; - array_pop($this->global->formsStack); + $this->global->forms->end(); %A% diff --git a/tests/Forms.Latte3/expected/forms.formContainer.php b/tests/Forms.Latte3/expected/forms.formContainer.php index 893cc8e3a..6bd65b4e0 100644 --- a/tests/Forms.Latte3/expected/forms.formContainer.php +++ b/tests/Forms.Latte3/expected/forms.formContainer.php @@ -1,46 +1,45 @@ global->formsStack[] = $this->global->uiControl['myForm'] /* line %d% */; - Nette\Bridges\FormsLatte\Runtime::initializeForm($form); - echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form, []) /* line %d% */; + $this->global->forms->begin($form = $this->global->uiControl['myForm']) /* line %d% */; + echo $this->global->forms->renderFormBegin([]) /* line %d% */; echo ' '; - $this->global->formsStack[] = $formContainer = Nette\Bridges\FormsLatte\Runtime::item('cont1', $this->global) /* line %d% */; + $this->global->forms->begin($formContainer = $this->global->forms->item('cont1')) /* line %d% */; echo ' '; - array_pop($this->global->formsStack); - $formContainer = end($this->global->formsStack); + $this->global->forms->end(); + $formContainer = $this->global->forms->current(); - $this->global->formsStack[] = $formContainer = Nette\Bridges\FormsLatte\Runtime::item('items', $this->global) /* line %d% */; + $this->global->forms->begin($formContainer = $this->global->forms->item('items')) /* line %d% */; echo ' '; - array_pop($this->global->formsStack); - $formContainer = end($this->global->formsStack); + $this->global->forms->end(); + $formContainer = $this->global->forms->current(); echo '
'; - echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item('input1', $this->global)->getLabel()) /* line %d% */; + echo ($ʟ_label = $this->global->forms->item('input1')->getLabel()) /* line %d% */; echo ' '; - echo Nette\Bridges\FormsLatte\Runtime::item('input1', $this->global)->getControl() /* line %d% */; + echo $this->global->forms->item('input1')->getControl() /* line %d% */; echo '
'; - echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item('input2', $this->global)->getLabel()) /* line %d% */; + echo ($ʟ_label = $this->global->forms->item('input2')->getLabel()) /* line %d% */; echo ' '; - echo Nette\Bridges\FormsLatte\Runtime::item('input2', $this->global)->getControl() /* line %d% */; + echo $this->global->forms->item('input2')->getControl() /* line %d% */; echo '
'; - echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item('input3', $this->global)->getLabel()) /* line %d% */; + echo ($ʟ_label = $this->global->forms->item('input3')->getLabel()) /* line %d% */; echo ' '; - echo Nette\Bridges\FormsLatte\Runtime::item('input3', $this->global)->getControl() /* line %d% */; + echo $this->global->forms->item('input3')->getControl() /* line %d% */; echo '
Checkboxes '; - $this->global->formsStack[] = $formContainer = Nette\Bridges\FormsLatte\Runtime::item('cont2', $this->global) /* line %d% */; + $this->global->forms->begin($formContainer = $this->global->forms->item('cont2')) /* line %d% */; echo '
    '; foreach ($formContainer->controls as $name => $field) /* line %d% */ { echo '
  1. '; - echo Nette\Bridges\FormsLatte\Runtime::item($field, $this->global)->getControl() /* line %d% */; + echo $this->global->forms->item($field)->getControl() /* line %d% */; echo '
  2. '; @@ -48,24 +47,24 @@ echo '
'; - array_pop($this->global->formsStack); - $formContainer = end($this->global->formsStack); + $this->global->forms->end(); + $formContainer = $this->global->forms->current(); echo '
'; - echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item('input7', $this->global)->getLabel()) /* line %d% */; + echo ($ʟ_label = $this->global->forms->item('input7')->getLabel()) /* line %d% */; echo ' '; - echo Nette\Bridges\FormsLatte\Runtime::item('input7', $this->global)->getControl() /* line %d% */; + echo $this->global->forms->item('input7')->getControl() /* line %d% */; echo '
Items @@ -73,12 +72,12 @@ $items = [1, 2, 3] /* line %d% */; foreach ($items as $item) /* line %d% */ { if (!isset($formContainer[$item])) /* line %d% */ continue; - $this->global->formsStack[] = $formContainer = Nette\Bridges\FormsLatte\Runtime::item($item, $this->global) /* line %d% */; + $this->global->forms->begin($formContainer = $this->global->forms->item($item)) /* line %d% */; echo ' '; - echo Nette\Bridges\FormsLatte\Runtime::item('input', $this->global)->getControl() /* line %d% */; + echo $this->global->forms->item('input')->getControl() /* line %d% */; echo "\n"; - array_pop($this->global->formsStack); - $formContainer = end($this->global->formsStack); + $this->global->forms->end(); + $formContainer = $this->global->forms->current(); } @@ -86,18 +85,19 @@ echo '
'; - echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item('input8', $this->global)->getLabel()) /* line %d% */; + echo ($ʟ_label = $this->global->forms->item('input8')->getLabel()) /* line %d% */; echo ' '; - echo Nette\Bridges\FormsLatte\Runtime::item('input8', $this->global)->getControl() /* line %d% */; + echo $this->global->forms->item('input8')->getControl() /* line %d% */; echo '
'; - echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(array_pop($this->global->formsStack)) /* line %d% */; -%A% + echo $this->global->forms->renderFormEnd() /* line %d% */; + $this->global->forms->end(); +%A% \ No newline at end of file diff --git a/tests/Forms.Latte3/expected/forms.get.php b/tests/Forms.Latte3/expected/forms.get.php index 25af74d41..0fd2c1eda 100644 --- a/tests/Forms.Latte3/expected/forms.get.php +++ b/tests/Forms.Latte3/expected/forms.get.php @@ -1,21 +1,20 @@ global->formsStack[] = $this->global->uiControl['myForm'] /* line %d% */; - Nette\Bridges\FormsLatte\Runtime::initializeForm($form); - echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form, []) /* line %d% */; - echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(array_pop($this->global->formsStack)) /* line %d% */; + $this->global->forms->begin($form = $this->global->uiControl['myForm']) /* line %d% */; + echo $this->global->forms->renderFormBegin([]) /* line %d% */; + echo $this->global->forms->renderFormEnd() /* line %d% */; + $this->global->forms->end(); echo ' '; - $form = $this->global->formsStack[] = $this->global->uiControl['myForm'] /* line %d% */; - Nette\Bridges\FormsLatte\Runtime::initializeForm($form); + $this->global->forms->begin($form = $this->global->uiControl['myForm']) /* line %d% */; echo 'global->formsStack), [], false) /* line %d% */; + echo $this->global->forms->renderFormBegin([], false) /* line %d% */; echo '> '; - echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(end($this->global->formsStack), false) /* line %d% */; + echo $this->global->forms->renderFormEnd(false) /* line %d% */; echo ' '; - array_pop($this->global->formsStack); -%A% + $this->global->forms->end(); +%A% \ No newline at end of file diff --git a/tests/Forms.Latte3/expected/forms.php b/tests/Forms.Latte3/expected/forms.php index ee2a1a269..99e3316af 100644 --- a/tests/Forms.Latte3/expected/forms.php +++ b/tests/Forms.Latte3/expected/forms.php @@ -1,141 +1,140 @@ global->formsStack[] = $this->global->uiControl['myForm'] /* line %d% */; - Nette\Bridges\FormsLatte\Runtime::initializeForm($form); - echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form, ['id' => 'myForm', 'class' => 'ajax']) /* line %d% */; + $this->global->forms->begin($form = $this->global->uiControl['myForm']) /* line %d% */; + echo $this->global->forms->renderFormBegin(['id' => 'myForm', 'class' => 'ajax']) /* line %d% */; echo "\n"; foreach (['id', 'username', 'select', 'area', 'send'] as $name) /* line %d% */ { echo ' '; - echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item($name, $this->global)->getLabel()) /* line %d% */; + echo ($ʟ_label = $this->global->forms->item($name)->getLabel()) /* line %d% */; echo ' '; - echo Nette\Bridges\FormsLatte\Runtime::item($name, $this->global)->getControl()->addAttributes(['title' => 'Hello', 'size' => 10]) /* line %d% */; + echo $this->global->forms->item($name)->getControl()->addAttributes(['title' => 'Hello', 'size' => 10]) /* line %d% */; echo ' '; - echo LR\Filters::escapeHtmlText(Nette\Bridges\FormsLatte\Runtime::item($name, $this->global)->getError()) /* line %d% */; + echo LR\Filters::escapeHtmlText($this->global->forms->item($name)->getError()) /* line %d% */; echo '
'; - echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item($form[$name], $this->global)->getLabel())?->addAttributes(['title' => 'hello'])?->startTag() /* line %d% */; + echo ($ʟ_label = $this->global->forms->item($form[$name])->getLabel())?->addAttributes(['title' => 'hello'])?->startTag() /* line %d% */; echo ' '; - echo Nette\Bridges\FormsLatte\Runtime::item($form[$name], $this->global)->getControl()->addAttributes(['title' => 'Hello', 'size' => 10]) /* line %d% */; + echo $this->global->forms->item($form[$name])->getControl()->addAttributes(['title' => 'Hello', 'size' => 10]) /* line %d% */; echo ' '; echo $ʟ_label?->endTag() /* line %d% */; echo ' '; - echo LR\Filters::escapeHtmlText(Nette\Bridges\FormsLatte\Runtime::item($form[$name], $this->global)->getError()) /* line %d% */; + echo LR\Filters::escapeHtmlText($this->global->forms->item($form[$name])->getError()) /* line %d% */; echo "\n"; } echo ' '; - echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item($form['username'], $this->global)->getLabel()) /* line %d% */; + echo ($ʟ_label = $this->global->forms->item($form['username'])->getLabel()) /* line %d% */; echo ' global))->getLabelPart()->addAttributes(['title' => null])->attributes() /* line %d% */; + echo ($ʟ_input = $this->global->forms->item('username'))->getLabelPart()->addAttributes(['title' => null])->attributes() /* line %d% */; echo ' title=hello>Name global))->getControlPart()->addAttributes(['value' => null, 'type' => null, 'class' => null])->attributes() /* line %d% */; + echo ($ʟ_input = $this->global->forms->item('username'))->getControlPart()->addAttributes(['value' => null, 'type' => null, 'class' => null])->attributes() /* line %d% */; echo '> global))->getLabelPart()->attributes() /* line %d% */; + echo ($ʟ_input = $this->global->forms->item($form['username']))->getLabelPart()->attributes() /* line %d% */; echo '> global))->getLabelPart()->attributes() /* line %d% */; + echo ($ʟ_input = $this->global->forms->item($form['username']))->getLabelPart()->attributes() /* line %d% */; echo '>'; echo $ʟ_input->getLabelPart()->getHtml() /* line %d% */; echo ' global))->getControlPart()->attributes() /* line %d% */; + echo ($ʟ_input = $this->global->forms->item($form['username']))->getControlPart()->attributes() /* line %d% */; echo '> '; - echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item('my', $this->global)->getLabel()) /* line %d% */; - echo Nette\Bridges\FormsLatte\Runtime::item('my', $this->global)->getControl() /* line %d% */; + echo ($ʟ_label = $this->global->forms->item('my')->getLabel()) /* line %d% */; + echo $this->global->forms->item('my')->getControl() /* line %d% */; echo "\n"; - echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(array_pop($this->global->formsStack)) /* line %d% */; + echo $this->global->forms->renderFormEnd() /* line %d% */; + $this->global->forms->end(); echo ' '; - $form = $this->global->formsStack[] = $this->global->uiControl['myForm'] /* line %d% */; - Nette\Bridges\FormsLatte\Runtime::initializeForm($form); - echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form, []) /* line %d% */; - echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(array_pop($this->global->formsStack)) /* line %d% */; + $this->global->forms->begin($form = $this->global->uiControl['myForm']) /* line %d% */; + echo $this->global->forms->renderFormBegin([]) /* line %d% */; + echo $this->global->forms->renderFormEnd() /* line %d% */; + $this->global->forms->end(); echo ' '; - $form = $this->global->formsStack[] = $this->global->uiControl['myForm'] /* line %d% */; - Nette\Bridges\FormsLatte\Runtime::initializeForm($form); - echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form, []) /* line %d% */; + $this->global->forms->begin($form = $this->global->uiControl['myForm']) /* line %d% */; + echo $this->global->forms->renderFormBegin([]) /* line %d% */; echo "\n"; foreach ($form['sex']->items as $key => $label) /* line %d% */ { echo ' '; - echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item('sex', $this->global)->getLabelPart($key))?->startTag() /* line %d% */; + echo ($ʟ_label = $this->global->forms->item('sex')->getLabelPart($key))?->startTag() /* line %d% */; echo ' '; - echo Nette\Bridges\FormsLatte\Runtime::item('sex', $this->global)->getControlPart($key) /* line %d% */; + echo $this->global->forms->item('sex')->getControlPart($key) /* line %d% */; echo ' '; echo LR\Filters::escapeHtmlText($label) /* line %d% */; echo $ʟ_label?->endTag() /* line %d% */; echo ' global))->getLabelPart($key)->addAttributes(['title' => null])->attributes() /* line %d% */; + echo ($ʟ_input = $this->global->forms->item('sex'))->getLabelPart($key)->addAttributes(['title' => null])->attributes() /* line %d% */; echo ' title=hello> global))->getControlPart($key)->attributes() /* line %d% */; + echo ($ʟ_input = $this->global->forms->item('sex'))->getControlPart($key)->attributes() /* line %d% */; echo '> '; } echo 'global))->getLabelPart()->attributes() /* line %d% */; + echo ($ʟ_input = $this->global->forms->item('sex'))->getLabelPart()->attributes() /* line %d% */; echo '> global))->getLabelPart()->attributes() /* line %d% */; + echo ($ʟ_input = $this->global->forms->item('sex'))->getLabelPart()->attributes() /* line %d% */; echo '>'; echo $ʟ_input->getLabelPart()->getHtml() /* line %d% */; echo ' global))->getLabelPart()->addAttributes(['title' => null])->attributes() /* line %d% */; + echo ($ʟ_input = $this->global->forms->item('sex'))->getLabelPart()->addAttributes(['title' => null])->attributes() /* line %d% */; echo ' title="hello">'; echo $ʟ_input->getLabelPart()->getHtml() /* line %d% */; echo ' global))->getControlPart("{$key}")->attributes() /* line %d% */; + echo ($ʟ_input = $this->global->forms->item($form['sex']))->getControlPart("{$key}")->attributes() /* line %d% */; echo '> '; - echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item('checkbox', $this->global)->getLabelPart(''))?->startTag() /* line %d% */; + echo ($ʟ_label = $this->global->forms->item('checkbox')->getLabelPart(''))?->startTag() /* line %d% */; echo ' '; - echo Nette\Bridges\FormsLatte\Runtime::item('checkbox', $this->global)->getControlPart('') /* line %d% */; + echo $this->global->forms->item('checkbox')->getControlPart('') /* line %d% */; echo ' Label'; echo $ʟ_label?->endTag() /* line %d% */; echo ' global))->getLabelPart('')->addAttributes(['title' => null])->attributes() /* line %d% */; + echo ($ʟ_input = $this->global->forms->item('checkbox'))->getLabelPart('')->addAttributes(['title' => null])->attributes() /* line %d% */; echo ' title=hello> global))->getControlPart('')->attributes() /* line %d% */; + echo ($ʟ_input = $this->global->forms->item('checkbox'))->getControlPart('')->attributes() /* line %d% */; echo '> global))->getLabelPart()->addAttributes(['title' => null])->attributes() /* line %d% */; + echo ($ʟ_input = $this->global->forms->item('checkbox'))->getLabelPart()->addAttributes(['title' => null])->attributes() /* line %d% */; echo ' title=hello> global))->getControlPart()->attributes() /* line %d% */; + echo ($ʟ_input = $this->global->forms->item('checkbox'))->getControlPart()->attributes() /* line %d% */; echo '> global))->getLabelPart('')->attributes() /* line %d% */; + echo ($ʟ_input = $this->global->forms->item('checkbox'))->getLabelPart('')->attributes() /* line %d% */; echo '>'; echo $ʟ_input->getLabelPart()->getHtml() /* line %d% */; echo ' global))->getLabelPart()->addAttributes(['title' => null])->attributes() /* line %d% */; + echo ($ʟ_input = $this->global->forms->item('checkbox'))->getLabelPart()->addAttributes(['title' => null])->attributes() /* line %d% */; echo ' title=hello>'; echo $ʟ_input->getLabelPart()->getHtml() /* line %d% */; echo ' @@ -144,32 +143,32 @@ '; foreach ($form['checklist']->items as $key => $label) /* line %d% */ { echo ' '; - echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item('checklist', $this->global)->getLabelPart($key))?->startTag() /* line %d% */; + echo ($ʟ_label = $this->global->forms->item('checklist')->getLabelPart($key))?->startTag() /* line %d% */; echo ' '; - echo Nette\Bridges\FormsLatte\Runtime::item('checklist', $this->global)->getControlPart($key) /* line %d% */; + echo $this->global->forms->item('checklist')->getControlPart($key) /* line %d% */; echo ' '; echo LR\Filters::escapeHtmlText($label) /* line %d% */; echo $ʟ_label?->endTag() /* line %d% */; echo ' global))->getLabelPart($key)->attributes() /* line %d% */; + echo ($ʟ_input = $this->global->forms->item('checklist'))->getLabelPart($key)->attributes() /* line %d% */; echo '> global))->getControlPart($key)->addAttributes(['title' => null])->attributes() /* line %d% */; + echo ($ʟ_input = $this->global->forms->item('checklist'))->getControlPart($key)->addAttributes(['title' => null])->attributes() /* line %d% */; echo ' title=hello> '; } echo 'global))->getLabelPart()->attributes() /* line %d% */; + echo ($ʟ_input = $this->global->forms->item('checklist'))->getLabelPart()->attributes() /* line %d% */; echo '> global))->getLabelPart()->attributes() /* line %d% */; + echo ($ʟ_input = $this->global->forms->item('checklist'))->getLabelPart()->attributes() /* line %d% */; echo '>'; echo $ʟ_input->getLabelPart()->getHtml() /* line %d% */; echo ' global))->getLabelPart()->addAttributes(['title' => null])->attributes() /* line %d% */; + echo ($ʟ_input = $this->global->forms->item('checklist'))->getLabelPart()->addAttributes(['title' => null])->attributes() /* line %d% */; echo ' title="hello">'; echo $ʟ_input->getLabelPart()->getHtml() /* line %d% */; echo ' @@ -177,65 +176,62 @@ '; if (1) /* line %d% */ { - $form = $this->global->formsStack[] = $this->global->uiControl['myForm'] /* line %d% */; - Nette\Bridges\FormsLatte\Runtime::initializeForm($form); + $this->global->forms->begin($form = $this->global->uiControl['myForm']) /* line %d% */; echo 'global->formsStack), ['id' => null, 'class' => null], false) /* line %d% */; + echo $this->global->forms->renderFormBegin(['id' => null, 'class' => null], false) /* line %d% */; echo ' id="myForm" class="ajax"> global))->getControlPart()->attributes() /* line %d% */; + echo ($ʟ_input = $this->global->forms->item('username'))->getControlPart()->attributes() /* line %d% */; echo '> '; - echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(end($this->global->formsStack), false) /* line %d% */; + echo $this->global->forms->renderFormEnd(false) /* line %d% */; echo ' '; - array_pop($this->global->formsStack); + $this->global->forms->end(); } echo ' '; - $form = $this->global->formsStack[] = $this->global->uiControl['myForm'] /* line %d% */; - Nette\Bridges\FormsLatte\Runtime::initializeForm($form); + $this->global->forms->begin($form = $this->global->uiControl['myForm']) /* line %d% */; echo 'global->formsStack), ['class' => null], false) /* line %d% */; + echo $this->global->forms->renderFormBegin(['class' => null], false) /* line %d% */; echo ($ʟ_tmp = array_filter(['nclass'])) ? ' class="' . LR\Filters::escapeHtmlAttr(implode(" ", array_unique($ʟ_tmp))) . '"' : "" /* line %d% */; echo '> global))->getControlPart()->addAttributes(['class' => null])->attributes() /* line %d% */; + echo ($ʟ_input = $this->global->forms->item('username'))->getControlPart()->addAttributes(['class' => null])->attributes() /* line %d% */; echo ($ʟ_tmp = array_filter(['nclass'])) ? ' class="' . LR\Filters::escapeHtmlAttr(implode(" ", array_unique($ʟ_tmp))) . '"' : "" /* line %d% */; echo '> '; - echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(end($this->global->formsStack), false) /* line %d% */; + echo $this->global->forms->renderFormEnd(false) /* line %d% */; echo ' '; - array_pop($this->global->formsStack); + $this->global->forms->end(); echo ' '; - $form = $this->global->formsStack[] = is_object($ʟ_tmp = $this->global->uiControl['myForm']) ? $ʟ_tmp : $this->global->uiControl[$ʟ_tmp] /* line %d% */; - Nette\Bridges\FormsLatte\Runtime::initializeForm($form); + $this->global->forms->begin($form = (is_object($ʟ_tmp = $this->global->uiControl['myForm']) ? $ʟ_tmp : $this->global->uiControl[$ʟ_tmp])) /* line %d% */; echo 'global->formsStack), [], false) /* line %d% */; + echo $this->global->forms->renderFormBegin([], false) /* line %d% */; echo '> global))->getControlPart()->attributes() /* line %d% */; + echo ($ʟ_input = $this->global->forms->item('username'))->getControlPart()->attributes() /* line %d% */; echo '> '; - echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(end($this->global->formsStack), false) /* line %d% */; + echo $this->global->forms->renderFormEnd(false) /* line %d% */; echo ' '; - array_pop($this->global->formsStack); + $this->global->forms->end(); echo ' global))->getControlPart()->attributes() /* line %d% */; + echo ($ʟ_input = $this->global->forms->item('select'))->getControlPart()->attributes() /* line %d% */; echo '>'; echo $ʟ_input->getControl()->getHtml() /* line %d% */; echo ' global))->getControlPart()->addAttributes(['title' => null])->attributes() /* line %d% */; + echo ($ʟ_input = $this->global->forms->item('area'))->getControlPart()->addAttributes(['title' => null])->attributes() /* line %d% */; echo ' title="'; echo LR\Filters::escapeHtmlAttr(10) /* line %d% */; echo '">'; @@ -244,28 +240,29 @@ global))->getControlPart()->attributes() /* line %d% */; + echo ($ʟ_input = $this->global->forms->item('select'))->getControlPart()->attributes() /* line %d% */; echo '>'; echo $ʟ_input->getControl()->getHtml() /* line %d% */; echo ' '; - echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(array_pop($this->global->formsStack)) /* line %d% */; + echo $this->global->forms->renderFormEnd() /* line %d% */; + $this->global->forms->end(); echo ' '; - $form = $this->global->formsStack[] = $this->global->uiControl['myForm'] /* line %d% */; - Nette\Bridges\FormsLatte\Runtime::initializeForm($form); + $this->global->forms->begin($form = $this->global->uiControl['myForm']) /* line %d% */; echo ' global))->getLabelPart()->attributes() /* line %d% */; + echo ($ʟ_input = $this->global->forms->item('sex'))->getLabelPart()->attributes() /* line %d% */; echo '>'; echo $ʟ_input->getLabelPart()->getHtml() /* line %d% */; echo ' global))->getControlPart()->attributes() /* line %d% */; + echo ($ʟ_input = $this->global->forms->item('username'))->getControlPart()->attributes() /* line %d% */; echo '> '; - array_pop($this->global->formsStack) /* line %d% */; -%A% + /* line %d% */; + $this->global->forms->end(); +%A% \ No newline at end of file diff --git a/tests/Forms.Latte3/n-name.form.phpt b/tests/Forms.Latte3/n-name.form.phpt index 6440b6a9d..7dd33928f 100644 --- a/tests/Forms.Latte3/n-name.form.phpt +++ b/tests/Forms.Latte3/n-name.form.phpt @@ -15,14 +15,13 @@ $latte->addExtension(new FormsExtension); Assert::match( <<<'XX' %A% - $form = $this->global->formsStack[] = $this->global->uiControl['foo'] /* line 1 */; - Nette\Bridges\FormsLatte\Runtime::initializeForm($form); + $this->global->forms->begin($form = $this->global->uiControl['foo']) /* line 1 */; echo 'global->formsStack), [], false) /* line 1 */; + echo $this->global->forms->renderFormBegin([], false) /* line 1 */; echo '>'; - echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(end($this->global->formsStack), false) /* line 1 */; + echo $this->global->forms->renderFormEnd(false) /* line 1 */; echo ''; - array_pop($this->global->formsStack); + $this->global->forms->end(); %A% XX, $latte->compile('
'), @@ -32,19 +31,18 @@ Assert::match( Assert::match( <<<'XX' %A% - $form = $this->global->formsStack[] = $this->global->uiControl['foo'] /* line 1 */; - Nette\Bridges\FormsLatte\Runtime::initializeForm($form); + $this->global->forms->begin($form = $this->global->uiControl['foo']) /* line 1 */; $ʟ_tag[0] = ''; if (0) /* line 1 */ { echo '<'; echo $ʟ_tmp = 'form' /* line 1 */; $ʟ_tag[0] = '' . $ʟ_tag[0]; - echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin(end($this->global->formsStack), [], false) /* line 1 */; + echo $this->global->forms->renderFormBegin([], false) /* line 1 */; echo '>'; } - echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(end($this->global->formsStack), false) /* line 1 */; + echo $this->global->forms->renderFormEnd(false) /* line 1 */; echo $ʟ_tag[0]; - array_pop($this->global->formsStack); + $this->global->forms->end(); %A% XX, $latte->compile('
'), diff --git a/tests/Forms.Latte3/n-name.input.phpt b/tests/Forms.Latte3/n-name.input.phpt index a32652568..0dd0e4c6f 100644 --- a/tests/Forms.Latte3/n-name.input.phpt +++ b/tests/Forms.Latte3/n-name.input.phpt @@ -13,12 +13,12 @@ $latte->setLoader(new Latte\Loaders\StringLoader); $latte->addExtension(new FormsExtension); Assert::match( - '%A%echo ($ʟ_input = Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global))->getControlPart()->attributes() %A%', + '%A%echo ($ʟ_input = $this->global->forms->item(\'foo\'))->getControlPart()->attributes() %A%', $latte->compile(''), ); Assert::match( - '%A%echo ($ʟ_input = Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global))->getControlPart(\'\')->attributes() %A%', + '%A%echo ($ʟ_input = $this->global->forms->item(\'foo\'))->getControlPart(\'\')->attributes() %A%', $latte->compile(''), ); @@ -29,11 +29,11 @@ Assert::exception( ); Assert::match( - '%A%echo ($ʟ_input = Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global))->getControlPart(\'x\')->attributes() %A%', + '%A%echo ($ʟ_input = $this->global->forms->item(\'foo\'))->getControlPart(\'x\')->attributes() %A%', $latte->compile(''), ); Assert::match( - '%A%echo ($ʟ_input = Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global))->getControlPart(\'x\')->attributes() %A%', + '%A%echo ($ʟ_input = $this->global->forms->item(\'foo\'))->getControlPart(\'x\')->attributes() %A%', $latte->compile(''), ); diff --git a/tests/Forms.Latte3/{input}.phpt b/tests/Forms.Latte3/{input}.phpt index e71ef81c8..02b236220 100644 --- a/tests/Forms.Latte3/{input}.phpt +++ b/tests/Forms.Latte3/{input}.phpt @@ -13,22 +13,22 @@ $latte->setLoader(new Latte\Loaders\StringLoader); $latte->addExtension(new FormsExtension); Assert::match( - '%A%echo Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getControl() %A%', + '%A%echo $this->global->forms->item(\'foo\')->getControl() %A%', $latte->compile('{input foo}'), ); Assert::match( - '%A%echo Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getControl()->addAttributes([\'class\' => \'foo\']) %A%', + '%A%echo $this->global->forms->item(\'foo\')->getControl()->addAttributes([\'class\' => \'foo\']) %A%', $latte->compile('{input foo class => foo}'), ); Assert::match( - '%A%echo Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getControl()->addAttributes([\'class\' => \'foo\']) %A%', + '%A%echo $this->global->forms->item(\'foo\')->getControl()->addAttributes([\'class\' => \'foo\']) %A%', $latte->compile('{input foo, class => foo}'), ); Assert::match( - '%A%echo Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getControlPart(\'\') %A%', + '%A%echo $this->global->forms->item(\'foo\')->getControlPart(\'\') %A%', $latte->compile('{input foo:}'), ); @@ -39,31 +39,31 @@ Assert::exception( ); Assert::match( - '%A%echo Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getControlPart(\'\') %A%', + '%A%echo $this->global->forms->item(\'foo\')->getControlPart(\'\') %A%', $latte->compile('{input foo:,}'), ); Assert::match( - '%A%echo Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getControlPart(\'\')->addAttributes([\'class\' => \'foo\']) %A%', + '%A%echo $this->global->forms->item(\'foo\')->getControlPart(\'\')->addAttributes([\'class\' => \'foo\']) %A%', $latte->compile('{input foo:, class => foo}'), ); Assert::match( - '%A%echo Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getControlPart(\'x\') %A%', + '%A%echo $this->global->forms->item(\'foo\')->getControlPart(\'x\') %A%', $latte->compile('{input foo:x}'), ); Assert::match( - '%A%echo Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getControlPart(\'x\')->addAttributes([\'class\' => \'foo\']) %A%', + '%A%echo $this->global->forms->item(\'foo\')->getControlPart(\'x\')->addAttributes([\'class\' => \'foo\']) %A%', $latte->compile('{input foo:x, class => foo}'), ); Assert::match( - '%A%echo Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getControlPart(\'x\') %A%', + '%A%echo $this->global->forms->item(\'foo\')->getControlPart(\'x\') %A%', $latte->compile('{input "foo":"x"}'), ); Assert::match( - '%A%echo Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getControlPart(\'x\') %A%', + '%A%echo $this->global->forms->item(\'foo\')->getControlPart(\'x\') %A%', $latte->compile('{input "foo" : "x"}'), ); diff --git a/tests/Forms.Latte3/{label}.phpt b/tests/Forms.Latte3/{label}.phpt index d28604202..b09ceca04 100644 --- a/tests/Forms.Latte3/{label}.phpt +++ b/tests/Forms.Latte3/{label}.phpt @@ -13,22 +13,22 @@ $latte->setLoader(new Latte\Loaders\StringLoader); $latte->addExtension(new FormsExtension); Assert::match( - '%A%echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getLabel()) %A%', + '%A%echo ($ʟ_label = $this->global->forms->item(\'foo\')->getLabel()) %A%', $latte->compile('{label foo /}'), ); Assert::match( - '%A%echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getLabel())?->addAttributes([\'class\' => \'foo\']) %A%', + '%A%echo ($ʟ_label = $this->global->forms->item(\'foo\')->getLabel())?->addAttributes([\'class\' => \'foo\']) %A%', $latte->compile('{label foo class => foo /}'), ); Assert::match( - '%A%echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getLabel())?->addAttributes([\'class\' => \'foo\']) %A%', + '%A%echo ($ʟ_label = $this->global->forms->item(\'foo\')->getLabel())?->addAttributes([\'class\' => \'foo\']) %A%', $latte->compile('{label foo, class => foo /}'), ); Assert::match( - '%A%echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getLabelPart(\'\')) %A%', + '%A%echo ($ʟ_label = $this->global->forms->item(\'foo\')->getLabelPart(\'\')) %A%', $latte->compile('{label foo: /}'), ); @@ -39,31 +39,31 @@ Assert::exception( ); Assert::match( - '%A%echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getLabelPart(\'\')) %A%', + '%A%echo ($ʟ_label = $this->global->forms->item(\'foo\')->getLabelPart(\'\')) %A%', $latte->compile('{label foo:, /}'), ); Assert::match( - '%A%echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getLabelPart(\'\'))?->addAttributes([\'class\' => \'foo\']) %A%', + '%A%echo ($ʟ_label = $this->global->forms->item(\'foo\')->getLabelPart(\'\'))?->addAttributes([\'class\' => \'foo\']) %A%', $latte->compile('{label foo:, class => foo /}'), ); Assert::match( - '%A%echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getLabelPart(\'x\')) %A%', + '%A%echo ($ʟ_label = $this->global->forms->item(\'foo\')->getLabelPart(\'x\')) %A%', $latte->compile('{label foo:x /}'), ); Assert::match( - '%A%echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getLabelPart(\'x\'))?->addAttributes([\'class\' => \'foo\']) %A%', + '%A%echo ($ʟ_label = $this->global->forms->item(\'foo\')->getLabelPart(\'x\'))?->addAttributes([\'class\' => \'foo\']) %A%', $latte->compile('{label foo:x, class => foo /}'), ); Assert::match( - '%A%echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getLabelPart(\'x\')) %A%', + '%A%echo ($ʟ_label = $this->global->forms->item(\'foo\')->getLabelPart(\'x\')) %A%', $latte->compile('{label "foo":"x" /}'), ); Assert::match( - '%A%echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getLabelPart(\'x\')) %A%', + '%A%echo ($ʟ_label = $this->global->forms->item(\'foo\')->getLabelPart(\'x\')) %A%', $latte->compile('{label "foo" : "x" /}'), );