diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 9c579d8ed..7a657ee70 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -10,7 +10,7 @@ jobs: - uses: actions/checkout@v4 - uses: shivammathur/setup-php@v2 with: - php-version: 8.1 + php-version: 8.2 coverage: none - run: composer install --no-progress --prefer-dist diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 519de812f..384001663 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php: ['8.1', '8.2', '8.3', '8.4', '8.5'] + php: ['8.2', '8.3', '8.4', '8.5'] fail-fast: false @@ -35,7 +35,7 @@ jobs: - uses: actions/checkout@v4 - uses: shivammathur/setup-php@v2 with: - php-version: 8.1 + php-version: 8.2 coverage: none - run: composer update --no-progress --prefer-dist --prefer-lowest --prefer-stable @@ -49,7 +49,7 @@ jobs: - uses: actions/checkout@v4 - uses: shivammathur/setup-php@v2 with: - php-version: 8.1 + php-version: 8.2 coverage: none - run: composer install --no-progress --prefer-dist diff --git a/composer.json b/composer.json index 6a343bb3a..c9967f703 100644 --- a/composer.json +++ b/composer.json @@ -15,21 +15,21 @@ } ], "require": { - "php": "8.1 - 8.5", - "nette/component-model": "^3.1", + "php": "8.2 - 8.5", + "nette/component-model": "^3.2", "nette/http": "^3.3", - "nette/utils": "^4.0.4" + "nette/utils": "^4.0.10" }, "require-dev": { - "nette/application": "^3.0", - "nette/di": "^3.0", + "nette/application": "^3.3", + "nette/di": "^3.2", "nette/tester": "^2.5.2", - "latte/latte": "^2.10.2 || ^3.0.12", - "tracy/tracy": "^2.9", + "latte/latte": "^3.1", + "tracy/tracy": "^2.11", "phpstan/phpstan-nette": "^2.0@stable" }, "conflict": { - "latte/latte": ">=3.0.0 <3.0.12 || >=3.2" + "latte/latte": "<3.1 || >=3.2" }, "suggest": { "ext-intl": "to use date/time controls" @@ -47,7 +47,7 @@ }, "extra": { "branch-alias": { - "dev-master": "3.2-dev" + "dev-master": "4.0-dev" } } } diff --git a/readme.md b/readme.md index ebcd0fd44..cd6f8a895 100644 --- a/readme.md +++ b/readme.md @@ -2,8 +2,8 @@ Nette Forms: greatly facilitates web forms ========================================== [![Downloads this Month](https://img.shields.io/packagist/dm/nette/forms.svg)](https://packagist.org/packages/nette/forms) -[![Tests](https://github.com/nette/forms/actions/workflows/tests.yml/badge.svg?branch=v3.2)](https://github.com/nette/forms/actions) -[![Coverage Status](https://coveralls.io/repos/github/nette/forms/badge.svg?branch=v3.2)](https://coveralls.io/github/nette/forms?branch=v3.2) +[![Tests](https://github.com/nette/forms/actions/workflows/tests.yml/badge.svg?branch=master)](https://github.com/nette/forms/actions) +[![Coverage Status](https://coveralls.io/repos/github/nette/forms/badge.svg?branch=master)](https://coveralls.io/github/nette/forms?branch=master) [![Latest Stable Version](https://poser.pugx.org/nette/forms/v/stable)](https://github.com/nette/forms/releases) [![License](https://img.shields.io/badge/license-New%20BSD-blue.svg)](https://github.com/nette/forms/blob/master/license.md) diff --git a/rollup.config.js b/rollup.config.js index 8a3697543..95ba912a3 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -34,21 +34,21 @@ function spaces2tabs() { export default [ - { + { // TODO: consider the possibility of cutting off the UMD versions completely due to collision input: 'src/assets/index.umd.ts', output: [ { format: 'umd', name: 'Nette', - dir: 'src/assets', - entryFileNames: 'netteForms.js', + dir: 'src/assets/dist', + entryFileNames: 'nette-forms.umd.js', generatedCode: 'es2015', }, { format: 'umd', name: 'Nette', - dir: 'src/assets', - entryFileNames: 'netteForms.min.js', + dir: 'src/assets/dist', + entryFileNames: 'nette-forms.umd.min.js', generatedCode: 'es2015', plugins: [ terser(), @@ -65,9 +65,36 @@ export default [ }, { - input: 'src/assets/index.umd.ts', + input: 'src/assets/index.esm.ts', + output: [ + { + format: 'es', + dir: 'src/assets/dist', + entryFileNames: 'nette-forms.esm.js', + generatedCode: 'es2015', + }, + { + format: 'es', + dir: 'src/assets/dist', + entryFileNames: 'nette-forms.esm.min.js', + generatedCode: 'es2015', + plugins: [ + terser(), + ], + }, + ], + plugins: [ + json(), + nodeResolve(), + typescript(), + spaces2tabs(), + ], + }, + + { + input: 'src/assets/index.esm.ts', output: [{ - file: 'src/assets/netteForms.d.ts', + file: 'src/assets/dist/nette-forms.d.ts', format: 'es', }], plugins: [ diff --git a/src/Bridges/FormsLatte/FormMacros.php b/src/Bridges/FormsLatte/FormMacros.php deleted file mode 100644 index 18c889ad2..000000000 --- a/src/Bridges/FormsLatte/FormMacros.php +++ /dev/null @@ -1,330 +0,0 @@ -addMacro('form', [$me, 'macroForm'], 'echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(array_pop($this->global->formsStack));'); - $me->addMacro('formContext', [$me, 'macroFormContext'], 'array_pop($this->global->formsStack);'); - $me->addMacro('formContainer', [$me, 'macroFormContainer'], 'array_pop($this->global->formsStack); $formContainer = end($this->global->formsStack)'); - $me->addMacro('label', [$me, 'macroLabel'], [$me, 'macroLabelEnd'], null, self::AUTO_EMPTY); - $me->addMacro('input', [$me, 'macroInput']); - $me->addMacro('name', [$me, 'macroName'], [$me, 'macroNameEnd'], [$me, 'macroNameAttr']); - $me->addMacro('inputError', [$me, 'macroInputError']); - $me->addMacro('formPrint', [$me, 'macroFormPrint']); - $me->addMacro('formClassPrint', [$me, 'macroFormPrint']); - } - - - /********************* macros ****************d*g**/ - - - /** - * {form ...} - */ - public function macroForm(MacroNode $node, PhpWriter $writer) - { - if ($node->modifiers) { - throw new CompileException('Modifiers are not allowed in ' . $node->getNotation()); - } - - if ($node->prefix) { - throw new CompileException('Did you mean
?'); - } - - $name = $node->tokenizer->fetchWord(); - if ($name == null) { // null or false - throw new CompileException('Missing form name in ' . $node->getNotation()); - } - - $node->replaced = true; - $node->tokenizer->reset(); - return $writer->write( - '$form = $this->global->formsStack[] = ' - . ($name[0] === '$' - ? 'is_object($ʟ_tmp = %node.word) ? $ʟ_tmp : $this->global->uiControl[$ʟ_tmp]' - : '$this->global->uiControl[%node.word]') - . ';' - . 'Nette\Bridges\FormsLatte\Runtime::initializeForm($form);' - . 'echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form, %node.array)' - . " /* line $node->startLine */;", - ); - } - - - /** - * {formContext ...} - */ - public function macroFormContext(MacroNode $node, PhpWriter $writer) - { - if ($node->modifiers) { - throw new CompileException('Modifiers are not allowed in ' . $node->getNotation()); - } - - if ($node->prefix) { - throw new CompileException('Did you mean ?'); - } - - $name = $node->tokenizer->fetchWord(); - if ($name == null) { // null or false - throw new CompileException('Missing form name in ' . $node->getNotation()); - } - - $node->tokenizer->reset(); - return $writer->write( - '$form = $this->global->formsStack[] = ' - . ($name[0] === '$' - ? 'is_object($ʟ_tmp = %node.word) ? $ʟ_tmp : $this->global->uiControl[$ʟ_tmp]' - : '$this->global->uiControl[%node.word]') - . " /* line $node->startLine */;", - ); - } - - - /** - * {formContainer ...} - */ - public function macroFormContainer(MacroNode $node, PhpWriter $writer) - { - if ($node->modifiers) { - throw new CompileException('Modifiers are not allowed in ' . $node->getNotation()); - } - - $name = $node->tokenizer->fetchWord(); - if ($name == null) { // null or false - throw new CompileException('Missing name in ' . $node->getNotation()); - } - - $node->tokenizer->reset(); - return $writer->write( - '$this->global->formsStack[] = $formContainer = ' - . ($name[0] === '$' - ? 'is_object($ʟ_tmp = %node.word) ? $ʟ_tmp : end($this->global->formsStack)[$ʟ_tmp]' - : 'end($this->global->formsStack)[%node.word]') - . " /* line $node->startLine */;", - ); - } - - - /** - * {label ...} - */ - public function macroLabel(MacroNode $node, PhpWriter $writer) - { - if ($node->modifiers) { - throw new CompileException('Modifiers are not allowed in ' . $node->getNotation()); - } - - $words = $node->tokenizer->fetchWords(); - if (!$words) { - throw new CompileException('Missing name in ' . $node->getNotation()); - } - - $node->replaced = true; - $name = array_shift($words); - return $writer->write( - ($name[0] === '$' - ? '$ʟ_input = is_object($ʟ_tmp = %0.word) ? $ʟ_tmp : end($this->global->formsStack)[$ʟ_tmp]; if ($ʟ_label = $ʟ_input' - : 'if ($ʟ_label = end($this->global->formsStack)[%0.word]' - ) - . '->%1.raw) echo $ʟ_label' - . ($node->tokenizer->isNext() ? '->addAttributes(%node.array)' : ''), - $name, - $words ? ('getLabelPart(' . implode(', ', array_map([$writer, 'formatWord'], $words)) . ')') : 'getLabel()', - ); - } - - - /** - * {/label} - */ - public function macroLabelEnd(MacroNode $node, PhpWriter $writer) - { - if ($node->content != null) { - $node->openingCode = rtrim($node->openingCode, '?> ') . '->startTag() ?>'; - return $writer->write('if ($ʟ_label) echo $ʟ_label->endTag()'); - } - } - - - /** - * {input ...} - */ - public function macroInput(MacroNode $node, PhpWriter $writer) - { - if ($node->modifiers) { - throw new CompileException('Modifiers are not allowed in ' . $node->getNotation()); - } - - $words = $node->tokenizer->fetchWords(); - if (!$words) { - throw new CompileException('Missing name in ' . $node->getNotation()); - } - - $node->replaced = true; - $name = array_shift($words); - return $writer->write( - ($name[0] === '$' - ? '$ʟ_input = $_input = is_object($ʟ_tmp = %word) ? $ʟ_tmp : end($this->global->formsStack)[$ʟ_tmp]; echo $ʟ_input' - : 'echo end($this->global->formsStack)[%word]') - . '->%raw' - . ($node->tokenizer->isNext() ? '->addAttributes(%node.array)' : '') - . " /* line $node->startLine */;", - $name, - $words ? 'getControlPart(' . implode(', ', array_map([$writer, 'formatWord'], $words)) . ')' : 'getControl()', - ); - } - - - /** - * , , + + +global->forms->item('select')->getControlPart())->attributes() /* pos %d%:9 */; + echo '>'; + echo $ʟ_elem->getHtml() /* pos %d%:9 */; + echo ' +'; + echo $this->global->forms->renderFormEnd() /* pos %d%:1 */; + $this->global->forms->end(); +%A% diff --git a/tests/Forms.Latte3/forms.button.phpt b/tests/Forms.Latte/forms.button.phpt similarity index 84% rename from tests/Forms.Latte3/forms.button.phpt rename to tests/Forms.Latte/forms.button.phpt index 136f44bd3..6e8aa59c1 100644 --- a/tests/Forms.Latte3/forms.button.phpt +++ b/tests/Forms.Latte/forms.button.phpt @@ -8,10 +8,6 @@ use Tester\Assert; require __DIR__ . '/../bootstrap.php'; -if (version_compare(Latte\Engine::VERSION, '3', '<')) { - Tester\Environment::skip('Test for Latte 3'); -} - $form = new Form; $form->addSubmit('send', 'Sign in'); diff --git a/tests/Forms.Latte3/forms.error.phpt b/tests/Forms.Latte/forms.error.phpt similarity index 93% rename from tests/Forms.Latte3/forms.error.phpt rename to tests/Forms.Latte/forms.error.phpt index b18a61a4a..f4a9c7dbf 100644 --- a/tests/Forms.Latte3/forms.error.phpt +++ b/tests/Forms.Latte/forms.error.phpt @@ -7,10 +7,6 @@ use Tester\Assert; require __DIR__ . '/../bootstrap.php'; -if (version_compare(Latte\Engine::VERSION, '3', '<')) { - Tester\Environment::skip('Test for Latte 3'); -} - $latte = new Latte\Engine; $latte->setLoader(new Latte\Loaders\StringLoader); diff --git a/tests/Forms.Latte3/forms.formContainer.phpt b/tests/Forms.Latte/forms.formContainer.phpt similarity index 91% rename from tests/Forms.Latte3/forms.formContainer.phpt rename to tests/Forms.Latte/forms.formContainer.phpt index 51eb27da6..f22b3baae 100644 --- a/tests/Forms.Latte3/forms.formContainer.phpt +++ b/tests/Forms.Latte/forms.formContainer.phpt @@ -8,10 +8,6 @@ use Tester\Assert; require __DIR__ . '/../bootstrap.php'; -if (version_compare(Latte\Engine::VERSION, '3', '<')) { - Tester\Environment::skip('Test for Latte 3'); -} - $form = new Form; $form->addText('input1', 'Input 1'); diff --git a/tests/Forms.Latte3/forms.get.phpt b/tests/Forms.Latte/forms.get.phpt similarity index 85% rename from tests/Forms.Latte3/forms.get.phpt rename to tests/Forms.Latte/forms.get.phpt index e1dada478..a2fa0ffd8 100644 --- a/tests/Forms.Latte3/forms.get.phpt +++ b/tests/Forms.Latte/forms.get.phpt @@ -8,10 +8,6 @@ use Tester\Assert; require __DIR__ . '/../bootstrap.php'; -if (version_compare(Latte\Engine::VERSION, '3', '<')) { - Tester\Environment::skip('Test for Latte 3'); -} - $form = new Form; $form->setMethod('get'); diff --git a/tests/Forms.Latte3/forms.phpt b/tests/Forms.Latte/forms.phpt similarity index 93% rename from tests/Forms.Latte3/forms.phpt rename to tests/Forms.Latte/forms.phpt index 0cc769add..c7724fac7 100644 --- a/tests/Forms.Latte3/forms.phpt +++ b/tests/Forms.Latte/forms.phpt @@ -8,10 +8,6 @@ use Tester\Assert; require __DIR__ . '/../bootstrap.php'; -if (version_compare(Latte\Engine::VERSION, '3', '<')) { - Tester\Environment::skip('Test for Latte 3'); -} - class MyControl extends Nette\Forms\Controls\BaseControl { diff --git a/tests/Forms.Latte/n-name.form.phpt b/tests/Forms.Latte/n-name.form.phpt new file mode 100644 index 000000000..08f23ead6 --- /dev/null +++ b/tests/Forms.Latte/n-name.form.phpt @@ -0,0 +1,49 @@ +setLoader(new Latte\Loaders\StringLoader); +$latte->addExtension(new FormsExtension); + +Assert::match( + <<<'XX' + %A% + $this->global->forms->begin($form = $this->global->uiControl['foo']) /* pos 1:7 */; + echo 'global->forms->renderFormBegin([], false) /* pos 1:7 */; + echo '>'; + echo $this->global->forms->renderFormEnd(false) /* pos 1:7 */; + echo ''; + $this->global->forms->end(); + %A% + XX, + $latte->compile('
'), +); + + +Assert::match( + <<<'XX' + %A% + $this->global->forms->begin($form = $this->global->uiControl['foo']) /* pos 1:18 */; + $ʟ_tag = ''; + if (0) /* pos 1:7 */ { + $ʟ_tag = '' . $ʟ_tag; + echo 'global->forms->renderFormBegin([], false) /* pos 1:18 */; + echo '>'; + } + $ʟ_tags[0] = $ʟ_tag; + echo $this->global->forms->renderFormEnd(false) /* pos 1:18 */; + echo $ʟ_tags[0]; + $this->global->forms->end(); + %A% + XX, + $latte->compile('
'), +); diff --git a/tests/Forms.Latte3/n-name.input.phpt b/tests/Forms.Latte/n-name.input.phpt similarity index 53% rename from tests/Forms.Latte3/n-name.input.phpt rename to tests/Forms.Latte/n-name.input.phpt index 0572ddb36..164845451 100644 --- a/tests/Forms.Latte3/n-name.input.phpt +++ b/tests/Forms.Latte/n-name.input.phpt @@ -7,22 +7,18 @@ use Tester\Assert; require __DIR__ . '/../bootstrap.php'; -if (version_compare(Latte\Engine::VERSION, '3', '<')) { - Tester\Environment::skip('Test for Latte 3'); -} - $latte = new Latte\Engine; $latte->setLoader(new Latte\Loaders\StringLoader); $latte->addExtension(new FormsExtension); Assert::match( - '%A%echo ($ʟ_elem = Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getControlPart())->attributes() %A%', + '%A%echo ($ʟ_elem = $this->global->forms->item(\'foo\')->getControlPart())->attributes() %A%', $latte->compile(''), ); Assert::match( - '%A%echo ($ʟ_elem = Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getControlPart(\'\'))->attributes() %A%', + '%A%echo ($ʟ_elem = $this->global->forms->item(\'foo\')->getControlPart(\'\'))->attributes() %A%', $latte->compile(''), ); @@ -33,11 +29,11 @@ Assert::exception( ); Assert::match( - '%A%echo ($ʟ_elem = Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getControlPart(\'x\'))->attributes() %A%', + '%A%echo ($ʟ_elem = $this->global->forms->item(\'foo\')->getControlPart(\'x\'))->attributes() %A%', $latte->compile(''), ); Assert::match( - '%A%echo ($ʟ_elem = Nette\Bridges\FormsLatte\Runtime::item(\'foo\', $this->global)->getControlPart(\'x\'))->attributes() %A%', + '%A%echo ($ʟ_elem = $this->global->forms->item(\'foo\')->getControlPart(\'x\'))->attributes() %A%', $latte->compile(''), ); diff --git a/tests/Forms.Latte2/templates/forms.button.latte b/tests/Forms.Latte/templates/forms.button.latte similarity index 100% rename from tests/Forms.Latte2/templates/forms.button.latte rename to tests/Forms.Latte/templates/forms.button.latte diff --git a/tests/Forms.Latte2/templates/forms.formContainer.latte b/tests/Forms.Latte/templates/forms.formContainer.latte similarity index 100% rename from tests/Forms.Latte2/templates/forms.formContainer.latte rename to tests/Forms.Latte/templates/forms.formContainer.latte diff --git a/tests/Forms.Latte2/templates/forms.get.latte b/tests/Forms.Latte/templates/forms.get.latte similarity index 100% rename from tests/Forms.Latte2/templates/forms.get.latte rename to tests/Forms.Latte/templates/forms.get.latte diff --git a/tests/Forms.Latte3/templates/forms.latte b/tests/Forms.Latte/templates/forms.latte similarity index 95% rename from tests/Forms.Latte3/templates/forms.latte rename to tests/Forms.Latte/templates/forms.latte index 9cb0a42ac..2634c63f5 100644 --- a/tests/Forms.Latte3/templates/forms.latte +++ b/tests/Forms.Latte/templates/forms.latte @@ -75,9 +75,3 @@ -{/formContext myForm} diff --git a/tests/Forms.Latte/{input}.phpt b/tests/Forms.Latte/{input}.phpt new file mode 100644 index 000000000..02b236220 --- /dev/null +++ b/tests/Forms.Latte/{input}.phpt @@ -0,0 +1,69 @@ +setLoader(new Latte\Loaders\StringLoader); +$latte->addExtension(new FormsExtension); + +Assert::match( + '%A%echo $this->global->forms->item(\'foo\')->getControl() %A%', + $latte->compile('{input foo}'), +); + +Assert::match( + '%A%echo $this->global->forms->item(\'foo\')->getControl()->addAttributes([\'class\' => \'foo\']) %A%', + $latte->compile('{input foo class => foo}'), +); + +Assert::match( + '%A%echo $this->global->forms->item(\'foo\')->getControl()->addAttributes([\'class\' => \'foo\']) %A%', + $latte->compile('{input foo, class => foo}'), +); + +Assert::match( + '%A%echo $this->global->forms->item(\'foo\')->getControlPart(\'\') %A%', + $latte->compile('{input foo:}'), +); + +Assert::exception( + fn() => $latte->compile('{input foo: class => foo}'), + Latte\CompileException::class, + "Unexpected '=>', expecting end of tag in {input} (on line 1 at column 19)", +); + +Assert::match( + '%A%echo $this->global->forms->item(\'foo\')->getControlPart(\'\') %A%', + $latte->compile('{input foo:,}'), +); + +Assert::match( + '%A%echo $this->global->forms->item(\'foo\')->getControlPart(\'\')->addAttributes([\'class\' => \'foo\']) %A%', + $latte->compile('{input foo:, class => foo}'), +); + +Assert::match( + '%A%echo $this->global->forms->item(\'foo\')->getControlPart(\'x\') %A%', + $latte->compile('{input foo:x}'), +); + +Assert::match( + '%A%echo $this->global->forms->item(\'foo\')->getControlPart(\'x\')->addAttributes([\'class\' => \'foo\']) %A%', + $latte->compile('{input foo:x, class => foo}'), +); + +Assert::match( + '%A%echo $this->global->forms->item(\'foo\')->getControlPart(\'x\') %A%', + $latte->compile('{input "foo":"x"}'), +); + +Assert::match( + '%A%echo $this->global->forms->item(\'foo\')->getControlPart(\'x\') %A%', + $latte->compile('{input "foo" : "x"}'), +); diff --git a/tests/Forms.Latte/{label}.phpt b/tests/Forms.Latte/{label}.phpt new file mode 100644 index 000000000..b09ceca04 --- /dev/null +++ b/tests/Forms.Latte/{label}.phpt @@ -0,0 +1,69 @@ +setLoader(new Latte\Loaders\StringLoader); +$latte->addExtension(new FormsExtension); + +Assert::match( + '%A%echo ($ʟ_label = $this->global->forms->item(\'foo\')->getLabel()) %A%', + $latte->compile('{label foo /}'), +); + +Assert::match( + '%A%echo ($ʟ_label = $this->global->forms->item(\'foo\')->getLabel())?->addAttributes([\'class\' => \'foo\']) %A%', + $latte->compile('{label foo class => foo /}'), +); + +Assert::match( + '%A%echo ($ʟ_label = $this->global->forms->item(\'foo\')->getLabel())?->addAttributes([\'class\' => \'foo\']) %A%', + $latte->compile('{label foo, class => foo /}'), +); + +Assert::match( + '%A%echo ($ʟ_label = $this->global->forms->item(\'foo\')->getLabelPart(\'\')) %A%', + $latte->compile('{label foo: /}'), +); + +Assert::exception( + fn() => $latte->compile('{label foo: class => foo /}'), + Latte\CompileException::class, + "Unexpected '=>', expecting end of tag in {label} (on line 1 at column 19)", +); + +Assert::match( + '%A%echo ($ʟ_label = $this->global->forms->item(\'foo\')->getLabelPart(\'\')) %A%', + $latte->compile('{label foo:, /}'), +); + +Assert::match( + '%A%echo ($ʟ_label = $this->global->forms->item(\'foo\')->getLabelPart(\'\'))?->addAttributes([\'class\' => \'foo\']) %A%', + $latte->compile('{label foo:, class => foo /}'), +); + +Assert::match( + '%A%echo ($ʟ_label = $this->global->forms->item(\'foo\')->getLabelPart(\'x\')) %A%', + $latte->compile('{label foo:x /}'), +); + +Assert::match( + '%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 = $this->global->forms->item(\'foo\')->getLabelPart(\'x\')) %A%', + $latte->compile('{label "foo":"x" /}'), +); + +Assert::match( + '%A%echo ($ʟ_label = $this->global->forms->item(\'foo\')->getLabelPart(\'x\')) %A%', + $latte->compile('{label "foo" : "x" /}'), +); diff --git a/tests/Forms.Latte2/FormMacros.button.phpt b/tests/Forms.Latte2/FormMacros.button.phpt deleted file mode 100644 index 549aedb31..000000000 --- a/tests/Forms.Latte2/FormMacros.button.phpt +++ /dev/null @@ -1,35 +0,0 @@ -')) { - Tester\Environment::skip('Test for Latte 2'); -} - - -$form = new Form; -$form->addSubmit('send', 'Sign in'); - -$latte = new Latte\Engine; -FormMacros::install($latte->getCompiler()); -$latte->addProvider('uiControl', ['myForm' => $form]); - -Assert::matchFile( - __DIR__ . '/expected/FormMacros.button.php', - $latte->compile(__DIR__ . '/templates/forms.button.latte'), -); - -Assert::matchFile( - __DIR__ . '/expected/FormMacros.button.html', - $latte->renderToString(__DIR__ . '/templates/forms.button.latte'), -); diff --git a/tests/Forms.Latte2/FormMacros.error.phpt b/tests/Forms.Latte2/FormMacros.error.phpt deleted file mode 100644 index 68dc2a5b0..000000000 --- a/tests/Forms.Latte2/FormMacros.error.phpt +++ /dev/null @@ -1,55 +0,0 @@ -')) { - Tester\Environment::skip('Test for Latte 2'); -} - - -$latte = new Latte\Engine; -$latte->setLoader(new Latte\Loaders\StringLoader); -FormMacros::install($latte->getCompiler()); - -Assert::exception(function () use ($latte) { - $latte->compile('
'); -}, Latte\CompileException::class, 'Did you mean
?'); - -Assert::exception(function () use ($latte) { - $latte->compile('
'); -}, Latte\CompileException::class, 'Missing name in n:name'); - -Assert::exception(function () use ($latte) { - $latte->compile('
'); -}, Latte\CompileException::class, 'Unknown attribute n:inner-name, use n:name attribute.'); - - -Assert::exception(function () use ($latte) { - $latte->compile('{form /}'); -}, Latte\CompileException::class, 'Missing form name in {form}'); - -Assert::exception(function () use ($latte) { - $latte->compile('{formContainer /}'); -}, Latte\CompileException::class, 'Missing name in {formContainer}'); - - -Assert::exception(function () use ($latte) { - $latte->compile('{label /}'); -}, Latte\CompileException::class, 'Missing name in {label}'); - -Assert::exception(function () use ($latte) { - $latte->compile('{input /}'); -}, Latte\CompileException::class, 'Missing name in {input}'); - -Assert::exception(function () use ($latte) { - $latte->compile('{name /}'); -}, Latte\CompileException::class, 'Unknown tag {name}, use n:name attribute.'); diff --git a/tests/Forms.Latte2/FormMacros.formContainer.phpt b/tests/Forms.Latte2/FormMacros.formContainer.phpt deleted file mode 100644 index a2d93c6e0..000000000 --- a/tests/Forms.Latte2/FormMacros.formContainer.phpt +++ /dev/null @@ -1,55 +0,0 @@ -')) { - Tester\Environment::skip('Test for Latte 2'); -} - - -$form = new Form; -$form->addText('input1', 'Input 1'); - -$cont1 = $form->addContainer('cont1'); -$cont1->addText('input2', 'Input 2'); -$cont1->addText('input3', 'Input 3'); - -$cont2 = $cont1->addContainer('cont2'); -$cont2->addCheckbox('input4', 'Input 4'); -$cont2->addCheckbox('input5', 'Input 5'); -$cont2->addCheckbox('input6', 'Input 6'); - -$cont1->addText('input7', 'Input 7'); - -$contItems = $form->addContainer('items'); -$items = [1, 3]; -foreach ($items as $item) { - $contItem = $contItems->addContainer($item); - $contItem->addText('input', 'Input'); -} - -$form->addSubmit('input8', 'Input 8'); - - -$latte = new Latte\Engine; -FormMacros::install($latte->getCompiler()); -$latte->addProvider('uiControl', ['myForm' => $form]); - -Assert::matchFile( - __DIR__ . '/expected/FormMacros.formContainer.php', - $latte->compile(__DIR__ . '/templates/forms.formContainer.latte'), -); -Assert::matchFile( - __DIR__ . '/expected/FormMacros.formContainer.html', - $latte->renderToString(__DIR__ . '/templates/forms.formContainer.latte'), -); diff --git a/tests/Forms.Latte2/FormMacros.forms.phpt b/tests/Forms.Latte2/FormMacros.forms.phpt deleted file mode 100644 index 6ff9a2b10..000000000 --- a/tests/Forms.Latte2/FormMacros.forms.phpt +++ /dev/null @@ -1,61 +0,0 @@ -')) { - Tester\Environment::skip('Test for Latte 2'); -} - - -class MyControl extends Nette\Forms\Controls\BaseControl -{ - public function getLabel($c = null) - { - return ''; - } - - - public function getControl() - { - return ''; - } -} - - -$form = new Form; -$form->getElementPrototype()->addClass('form-class'); -$form->addHidden('id'); -$form->addText('username', 'Username:'); // must have just one textfield to generate IE fix -$form['username']->getControlPrototype()->addClass('control-class'); -$form->addRadioList('sex', 'Sex:', ['m' => 'male', 'f' => 'female']); -$form->addSelect('select', null, ['m' => 'male', 'f' => 'female']); -$form->addTextArea('area', null)->setValue('oneaddCheckbox('checkbox', 'Checkbox'); -$form->addCheckboxList('checklist', 'CheckboxList:', ['m' => 'male', 'f' => 'female']); -$form->addSubmit('send', 'Sign in'); -$form['my'] = new MyControl; - -$latte = new Latte\Engine; -FormMacros::install($latte->getCompiler()); -$latte->addProvider('uiControl', ['myForm' => $form]); - -$form['username']->addError('error'); - -Assert::matchFile( - __DIR__ . '/expected/FormMacros.forms.php', - $latte->compile(__DIR__ . '/templates/forms.latte'), -); -Assert::matchFile( - __DIR__ . '/expected/FormMacros.forms.html', - $latte->renderToString(__DIR__ . '/templates/forms.latte'), -); diff --git a/tests/Forms.Latte2/FormMacros.get.phpt b/tests/Forms.Latte2/FormMacros.get.phpt deleted file mode 100644 index cb74c5d93..000000000 --- a/tests/Forms.Latte2/FormMacros.get.phpt +++ /dev/null @@ -1,36 +0,0 @@ -')) { - Tester\Environment::skip('Test for Latte 2'); -} - - -$form = new Form; -$form->setMethod('get'); -$form->setAction('?arg=val'); -$form->addSubmit('send', 'Sign in'); - -$latte = new Latte\Engine; -FormMacros::install($latte->getCompiler()); -$latte->addProvider('uiControl', ['myForm' => $form]); - -Assert::matchFile( - __DIR__ . '/expected/FormMacros.get.php', - $latte->compile(__DIR__ . '/templates/forms.get.latte'), -); -Assert::matchFile( - __DIR__ . '/expected/FormMacros.get.html', - $latte->renderToString(__DIR__ . '/templates/forms.get.latte'), -); diff --git a/tests/Forms.Latte2/expected/FormMacros.button.html b/tests/Forms.Latte2/expected/FormMacros.button.html deleted file mode 100644 index 30763a37a..000000000 --- a/tests/Forms.Latte2/expected/FormMacros.button.html +++ /dev/null @@ -1,9 +0,0 @@ -
- - - - - -
\ No newline at end of file diff --git a/tests/Forms.Latte2/expected/FormMacros.button.php b/tests/Forms.Latte2/expected/FormMacros.button.php deleted file mode 100644 index 984e031a8..000000000 --- a/tests/Forms.Latte2/expected/FormMacros.button.php +++ /dev/null @@ -1,30 +0,0 @@ -global->formsStack[] = $this->global->uiControl["myForm"] /* line 1 */; - Nette\Bridges\FormsLatte\Runtime::initializeForm($form); - echo 'global->formsStack), [], false); - echo '> - global->formsStack)["send"]; - echo $ʟ_input->getControlPart()->attributes() /* line 2 */; - echo '> - description of button - - - global->formsStack)["send"]; - echo $ʟ_input->getControlPart()->attributes() /* line 6 */; - echo '> - - global->formsStack)["send"]; - echo $ʟ_input->getControlPart()->attributes() /* line 8 */; - echo '>'; - echo LR\Filters::escapeHtmlText($ʟ_input->getCaption()) /* line 8 */; - echo ' -'; - echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(array_pop($this->global->formsStack), false) /* line 1 */; - echo ' -'; -%A% diff --git a/tests/Forms.Latte2/expected/FormMacros.formContainer.html b/tests/Forms.Latte2/expected/FormMacros.formContainer.html deleted file mode 100644 index 2e45cf0d6..000000000 --- a/tests/Forms.Latte2/expected/FormMacros.formContainer.html +++ /dev/null @@ -1,41 +0,0 @@ -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Checkboxes -
    -
  1. -
  2. -
  3. -
-
Items - - -
-
diff --git a/tests/Forms.Latte2/expected/FormMacros.formContainer.php b/tests/Forms.Latte2/expected/FormMacros.formContainer.php deleted file mode 100644 index 8b33447ec..000000000 --- a/tests/Forms.Latte2/expected/FormMacros.formContainer.php +++ /dev/null @@ -1,101 +0,0 @@ -global->formsStack[] = $this->global->uiControl["myForm"]; - Nette\Bridges\FormsLatte\Runtime::initializeForm($form); - echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form, []) /* line 1 */; - echo ' - - - - - -'; - $this->global->formsStack[] = $formContainer = end($this->global->formsStack)["cont1"] /* line 7 */; - echo ' - - - - - - - - - - - - - - - -'; - array_pop($this->global->formsStack); - $formContainer = end($this->global->formsStack); - $this->global->formsStack[] = $formContainer = end($this->global->formsStack)["items"] /* line 29 */; - echo ' - - - -'; - array_pop($this->global->formsStack); - $formContainer = end($this->global->formsStack); - echo ' - - - -
'; - if ($ʟ_label = end($this->global->formsStack)["input1"]->getLabel()) echo $ʟ_label; - echo ''; - echo end($this->global->formsStack)["input1"]->getControl() /* line 5 */; - echo '
'; - if ($ʟ_label = end($this->global->formsStack)["input2"]->getLabel()) echo $ʟ_label; - echo ''; - echo end($this->global->formsStack)["input2"]->getControl() /* line 10 */; - echo '
'; - if ($ʟ_label = end($this->global->formsStack)["input3"]->getLabel()) echo $ʟ_label; - echo ''; - echo end($this->global->formsStack)["input3"]->getControl() /* line 14 */; - echo '
Checkboxes -'; - $this->global->formsStack[] = $formContainer = end($this->global->formsStack)["cont2"] /* line 19 */; - echo '
    -'; - $iterations = 0; - foreach ($formContainer->controls as $name => $field) /* line 19 */ { - echo '
  1. '; - $ʟ_input = $_input = is_object($ʟ_tmp = $field) ? $ʟ_tmp : end($this->global->formsStack)[$ʟ_tmp]; - echo $ʟ_input->getControl() /* line 20 */; - echo '
  2. -'; - $iterations++; - } - echo '
-'; - array_pop($this->global->formsStack); - $formContainer = end($this->global->formsStack); - echo '
'; - if ($ʟ_label = end($this->global->formsStack)["input7"]->getLabel()) echo $ʟ_label; - echo ''; - echo end($this->global->formsStack)["input7"]->getControl() /* line 26 */; - echo '
Items -'; - $items = array(1, 2, 3) /* line 33 */; - $iterations = 0; - foreach ($items as $item) /* line 34 */ { - if (!isset($formContainer[$item])) /* line 35 */ continue; - $this->global->formsStack[] = $formContainer = is_object($ʟ_tmp = $item) ? $ʟ_tmp : end($this->global->formsStack)[$ʟ_tmp] /* line 36 */; - echo ' '; - echo end($this->global->formsStack)["input"]->getControl() /* line 37 */; - echo "\n"; - array_pop($this->global->formsStack); - $formContainer = end($this->global->formsStack); - $iterations++; - } - echo '
'; - if ($ʟ_label = end($this->global->formsStack)["input8"]->getLabel()) echo $ʟ_label; - echo ''; - echo end($this->global->formsStack)["input8"]->getControl() /* line 45 */; - echo '
-'; - echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(array_pop($this->global->formsStack)); - echo "\n"; -%A% diff --git a/tests/Forms.Latte2/expected/FormMacros.forms.html b/tests/Forms.Latte2/expected/FormMacros.forms.html deleted file mode 100644 index 8dffbcaf1..000000000 --- a/tests/Forms.Latte2/expected/FormMacros.forms.html +++ /dev/null @@ -1,118 +0,0 @@ -
- - - - - -
- - - - - - error - error - -
- - - error - - - - - -
- - - - - - - - -
- - - - - - - - -
- - - - - - - - - - - - - - -
- - - -
- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - -
- -
- - -
- -
- - - - - - - - - - - - - - - \ No newline at end of file diff --git a/tests/Forms.Latte2/expected/FormMacros.forms.php b/tests/Forms.Latte2/expected/FormMacros.forms.php deleted file mode 100644 index dda078042..000000000 --- a/tests/Forms.Latte2/expected/FormMacros.forms.php +++ /dev/null @@ -1,297 +0,0 @@ -global->formsStack[] = $this->global->uiControl["myForm"]; - Nette\Bridges\FormsLatte\Runtime::initializeForm($form); - echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form, ['id' => 'myForm', 'class'=>"ajax"]) /* line 1 */; - echo "\n"; - $iterations = 0; - foreach (['id', 'username', 'select', 'area', 'send'] as $name) /* line 2 */ { - echo ' '; - $ʟ_input = is_object($ʟ_tmp = $name) ? $ʟ_tmp : end($this->global->formsStack)[$ʟ_tmp]; - if ($ʟ_label = $ʟ_input->getLabel()) echo $ʟ_label; - echo ' - '; - $ʟ_input = $_input = is_object($ʟ_tmp = $name) ? $ʟ_tmp : end($this->global->formsStack)[$ʟ_tmp]; - echo $ʟ_input->getControl()->addAttributes(['title' => 'Hello', 'size' => 10]) /* line 4 */; - echo ' - '; - echo LR\Filters::escapeHtmlText($ʟ_input->getError()) /* line 5 */; - echo ' - '; - $ʟ_input = is_object($ʟ_tmp = $name) ? $ʟ_tmp : end($this->global->formsStack)[$ʟ_tmp]; - echo LR\Filters::escapeHtmlText($ʟ_input->getError()) /* line 6 */; - echo ' - -
- - '; - $ʟ_input = is_object($ʟ_tmp = $form[$name]) ? $ʟ_tmp : end($this->global->formsStack)[$ʟ_tmp]; - if ($ʟ_label = $ʟ_input->getLabel()) echo $ʟ_label->addAttributes(['title' => 'hello'])->startTag(); - echo ' '; - $ʟ_input = $_input = is_object($ʟ_tmp = $form[$name]) ? $ʟ_tmp : end($this->global->formsStack)[$ʟ_tmp]; - echo $ʟ_input->getControl()->addAttributes(['title' => 'Hello', 'size' => 10]) /* line 10 */; - echo ' '; - if ($ʟ_label) echo $ʟ_label->endTag(); - echo ' - '; - $ʟ_input = is_object($ʟ_tmp = $form[$name]) ? $ʟ_tmp : end($this->global->formsStack)[$ʟ_tmp]; - echo LR\Filters::escapeHtmlText($ʟ_input->getError()) /* line 11 */; - echo "\n"; - $iterations++; - } - echo ' - '; - $ʟ_input = is_object($ʟ_tmp = $form['username']) ? $ʟ_tmp : end($this->global->formsStack)[$ʟ_tmp]; - if ($ʟ_label = $ʟ_input->getLabel()) echo $ʟ_label; - echo ' - - - global->formsStack)["username"]; - echo $ʟ_input->getControlPart()->addAttributes(['value' => null, 'type' => null, 'class' => null])->attributes() /* line 17 */; - echo '> - - global->formsStack)[$ʟ_tmp]; - echo $ʟ_input->getLabelPart()->attributes() /* line 19 */; - echo '> - global->formsStack)[$ʟ_tmp]; - echo $ʟ_input->getLabelPart()->attributes() /* line 20 */; - echo '>'; - echo $ʟ_input->getLabelPart()->getHtml() /* line 20 */; - echo ' - global->formsStack)[$ʟ_tmp]; - echo $ʟ_input->getControlPart()->attributes() /* line 21 */; - echo '> - - '; - if ($ʟ_label = end($this->global->formsStack)["my"]->getLabel()) echo $ʟ_label; - echo end($this->global->formsStack)["my"]->getControl() /* line 23 */; - echo "\n"; - echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(array_pop($this->global->formsStack)); - echo ' - - -'; - $form = $this->global->formsStack[] = $this->global->uiControl["myForm"]; - Nette\Bridges\FormsLatte\Runtime::initializeForm($form); - echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form, []) /* line 27 */; - echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(array_pop($this->global->formsStack)); - echo ' - -'; - $form = $this->global->formsStack[] = $this->global->uiControl["myForm"]; - Nette\Bridges\FormsLatte\Runtime::initializeForm($form); - echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form, []) /* line 29 */; - echo "\n"; - $iterations = 0; - foreach ($form['sex']->items as $key => $label) /* line 31 */ { - echo ' '; - if ($ʟ_label = end($this->global->formsStack)["sex"]->getLabelPart($key)) echo $ʟ_label->startTag(); - echo ' '; - echo end($this->global->formsStack)["sex"]->getControlPart($key) /* line 32 */; - echo ' '; - echo LR\Filters::escapeHtmlText($label) /* line 32 */; - if ($ʟ_label) echo $ʟ_label->endTag(); - echo ' - -'; - $iterations++; - } - echo 'global->formsStack)["sex"]; - echo $ʟ_input->getLabelPart()->attributes() /* line 35 */; - echo '> -global->formsStack)["sex"]; - echo $ʟ_input->getLabelPart()->attributes() /* line 36 */; - echo '>'; - echo $ʟ_input->getLabelPart()->getHtml() /* line 36 */; - echo ' - - - -'; - if ($ʟ_label = end($this->global->formsStack)["checkbox"]->getLabelPart("")) echo $ʟ_label->startTag(); - echo ' '; - echo end($this->global->formsStack)["checkbox"]->getControlPart("") /* line 41 */; - echo ' Label'; - if ($ʟ_label) echo $ʟ_label->endTag(); - echo ' - - -global->formsStack)["checkbox"]; - echo $ʟ_input->getLabelPart("")->attributes() /* line 44 */; - echo '>'; - echo $ʟ_input->getLabelPart()->getHtml() /* line 44 */; - echo ' - - - -'; - $iterations = 0; - foreach ($form['checklist']->items as $key => $label) /* line 49 */ { - echo ' '; - if ($ʟ_label = end($this->global->formsStack)["checklist"]->getLabelPart($key)) echo $ʟ_label->startTag(); - echo ' '; - echo end($this->global->formsStack)["checklist"]->getControlPart($key) /* line 50 */; - echo ' '; - echo LR\Filters::escapeHtmlText($label) /* line 50 */; - if ($ʟ_label) echo $ʟ_label->endTag(); - echo ' - global->formsStack)["checklist"]; - echo $ʟ_input->getLabelPart($key)->attributes() /* line 51 */; - echo '> global->formsStack)["checklist"]; - echo $ʟ_input->getControlPart($key)->addAttributes(['title' => null])->attributes() /* line 51 */; - echo '> -'; - $iterations++; - } - echo 'global->formsStack)["checklist"]; - echo $ʟ_input->getLabelPart()->attributes() /* line 53 */; - echo '> -global->formsStack)["checklist"]; - echo $ʟ_input->getLabelPart()->attributes() /* line 54 */; - echo '>'; - echo $ʟ_input->getLabelPart()->getHtml() /* line 54 */; - echo ' - - - -'; - $form = $this->global->formsStack[] = $this->global->uiControl["myForm"] /* line 58 */; - Nette\Bridges\FormsLatte\Runtime::initializeForm($form); - if (1) /* line 58 */ { - echo '
global->formsStack), ['id' => null, 'class' => null], false); - echo '> - global->formsStack)["username"]; - echo $ʟ_input->getControlPart()->attributes() /* line 59 */; - echo '> -'; - echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(array_pop($this->global->formsStack), false) /* line 58 */; - echo ' -'; - } - echo ' - -'; - $form = $this->global->formsStack[] = $this->global->uiControl["myForm"] /* line 63 */; - Nette\Bridges\FormsLatte\Runtime::initializeForm($form); - echo 'global->formsStack), ['class' => null], false); - echo '> - global->formsStack)["username"]; - echo $ʟ_input->getControlPart()->addAttributes(['class' => null])->attributes() /* line 64 */; - echo ($ʟ_tmp = array_filter(['nclass'])) ? ' class="' . LR\Filters::escapeHtmlAttr(implode(" ", array_unique($ʟ_tmp))) . '"' : "" /* line 64 */; - echo '> -'; - echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(array_pop($this->global->formsStack), false) /* line 63 */; - echo ' - - -'; - $form = $this->global->formsStack[] = is_object($ʟ_tmp = $this->global->uiControl['myForm']) ? $ʟ_tmp : $this->global->uiControl[$ʟ_tmp] /* line 68 */; - Nette\Bridges\FormsLatte\Runtime::initializeForm($form); - echo 'global->formsStack), [], false); - echo '> - global->formsStack)["username"]; - echo $ʟ_input->getControlPart()->attributes() /* line 69 */; - echo '> -'; - echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(array_pop($this->global->formsStack), false) /* line 68 */; - echo ' - - -global->formsStack)["select"]; - echo $ʟ_input->getControlPart()->attributes() /* line 73 */; - echo '>'; - echo $ʟ_input->getControl()->getHtml() /* line 73 */; - echo ' - - - - - -global->formsStack)["select"]; - echo $ʟ_input->getControlPart()->attributes() /* line 79 */; - echo '>'; - echo $ʟ_input->getControl()->getHtml() /* line 79 */; - echo ' -'; - echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(array_pop($this->global->formsStack)); - echo ' - - -'; - $form = $this->global->formsStack[] = $this->global->uiControl["myForm"] /* line 83 */; - echo 'global->formsStack)["sex"]; - echo $ʟ_input->getLabelPart()->attributes() /* line 84 */; - echo '>'; - echo $ʟ_input->getLabelPart()->getHtml() /* line 84 */; - echo ' -global->formsStack)["username"]; - echo $ʟ_input->getControlPart()->attributes() /* line 85 */; - echo '> -'; - array_pop($this->global->formsStack); -%A% diff --git a/tests/Forms.Latte2/expected/FormMacros.get.html b/tests/Forms.Latte2/expected/FormMacros.get.html deleted file mode 100644 index e37282817..000000000 --- a/tests/Forms.Latte2/expected/FormMacros.get.html +++ /dev/null @@ -1,5 +0,0 @@ -
- - -
-
\ No newline at end of file diff --git a/tests/Forms.Latte2/expected/FormMacros.get.php b/tests/Forms.Latte2/expected/FormMacros.get.php deleted file mode 100644 index ae17372cd..000000000 --- a/tests/Forms.Latte2/expected/FormMacros.get.php +++ /dev/null @@ -1,19 +0,0 @@ -global->formsStack[] = $this->global->uiControl["myForm"]; - Nette\Bridges\FormsLatte\Runtime::initializeForm($form); - echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin($form, []) /* line 1 */; - echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(array_pop($this->global->formsStack)); - echo ' - -'; - $form = $this->global->formsStack[] = $this->global->uiControl["myForm"] /* line 3 */; - Nette\Bridges\FormsLatte\Runtime::initializeForm($form); - echo 'global->formsStack), [], false); - echo '> -'; - echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(array_pop($this->global->formsStack), false) /* line 3 */; - echo ' -'; -%A% diff --git a/tests/Forms.Latte2/templates/forms.latte b/tests/Forms.Latte2/templates/forms.latte deleted file mode 100644 index adf5a60c8..000000000 --- a/tests/Forms.Latte2/templates/forms.latte +++ /dev/null @@ -1,86 +0,0 @@ -{form myForm id => myForm, class=>"ajax"} - {foreach [id, username, select, area, send] as $name} - {label $name /} - {input $name title => Hello, size => 10} - {inputError} - {inputError $name} - -
- - {label $form[$name] title => hello} {input $form[$name] title => Hello, size => 10} {/label} - {inputError $form[$name]} - {/foreach} - - {label $form[username] /} - - - - - - -global)->getLabelPart())->addAttributes(['title' => null])->attributes() /* %a% */; - echo ' title="hello">'; - echo $ʟ_elem->getHtml() /* %a% */; - echo ' -global)->getControlPart("{$key}"))->attributes() /* %a% */; - echo '> - - -'; - echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item('checkbox', $this->global)->getLabelPart(''))?->startTag() /* %a% */; - echo ' '; - echo Nette\Bridges\FormsLatte\Runtime::item('checkbox', $this->global)->getControlPart('') /* %a% */; - echo ' Label'; - echo $ʟ_label?->endTag() /* %a% */; - echo ' -global)->getLabelPart(''))->addAttributes(['title' => null])->attributes() /* %a% */; - echo ' title=hello> global)->getControlPart(''))->attributes() /* %a% */; - echo '> -global)->getLabelPart())->addAttributes(['title' => null])->attributes() /* %a% */; - echo ' title=hello> global)->getControlPart())->attributes() /* %a% */; - echo '> -global)->getLabelPart(''))->attributes() /* %a% */; - echo '>'; - echo $ʟ_elem->getHtml() /* %a% */; - echo ' -global)->getLabelPart())->addAttributes(['title' => null])->attributes() /* %a% */; - echo ' title=hello>'; - echo $ʟ_elem->getHtml() /* %a% */; - echo ' - - -'; - foreach ($form['checklist']->items as $key => $label) /* %a% */ { - echo ' '; - echo ($ʟ_label = Nette\Bridges\FormsLatte\Runtime::item('checklist', $this->global)->getLabelPart($key))?->startTag() /* %a% */; - echo ' '; - echo Nette\Bridges\FormsLatte\Runtime::item('checklist', $this->global)->getControlPart($key) /* %a% */; - echo ' '; - echo LR\%a%::escape%a%($label) /* %a% */; - echo $ʟ_label?->endTag() /* %a% */; - echo ' - global)->getLabelPart($key))->attributes() /* %a% */; - echo '> global)->getControlPart($key))->addAttributes(['title' => null])->attributes() /* %a% */; - echo ' title=hello> - global)->getLabelPart($key))->attributes() /* %a% */; - echo '>'; - echo $ʟ_elem->getHtml() /* %a% */; - echo ' -'; - - } - - echo 'global)->getLabelPart())->attributes() /* %a% */; - echo '> -global)->getLabelPart())->attributes() /* %a% */; - echo '>'; - echo $ʟ_elem->getHtml() /* %a% */; - echo ' -global)->getLabelPart())->addAttributes(['title' => null])->attributes() /* %a% */; - echo ' title="hello">'; - echo $ʟ_elem->getHtml() /* %a% */; - echo ' - - -'; - if (1) /* %a% */ { - $form = $this->global->formsStack[] = $this->global->uiControl['myForm'] /* %a% */; - Nette\Bridges\FormsLatte\Runtime::initializeForm($form); - echo 'global->formsStack), ['id' => null, 'class' => null], false) /* %a% */; - echo ' id="myForm" class="ajax"> - global)->getControlPart())->attributes() /* %a% */; - echo '> -'; - echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(end($this->global->formsStack), false) /* %a% */; - echo ' -'; - array_pop($this->global->formsStack); - } - echo ' - -'; - $form = $this->global->formsStack[] = $this->global->uiControl['myForm'] /* %a% */; - Nette\Bridges\FormsLatte\Runtime::initializeForm($form); - echo 'global->formsStack), ['class' => null], false) /* %a% */; - echo ($ʟ_tmp = array_filter(['nclass'])) ? ' class="' . LR\%a%::escape%a%(implode(" ", array_unique($ʟ_tmp))) . '"' : "" /* %a% */; - echo '> - global)->getControlPart())->addAttributes(['class' => null])->attributes() /* %a% */; - echo ($ʟ_tmp = array_filter(['nclass'])) ? ' class="' . LR\%a%::escape%a%(implode(" ", array_unique($ʟ_tmp))) . '"' : "" /* %a% */; - echo '> -'; - echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(end($this->global->formsStack), false) /* %a% */; - echo ' -'; - array_pop($this->global->formsStack); - echo ' - -global)->getControlPart())->attributes() /* %a% */; - echo '>'; - echo $ʟ_elem->getHtml() /* %a% */; - echo ' - - -global)->getControlPart())->addAttributes(['title' => null])->attributes() /* %a% */; - %A% - echo $ʟ_elem->getHtml() /* %a% */; - echo ' - - -global)->getControlPart())->attributes() /* %a% */; - echo '>'; - echo $ʟ_elem->getHtml() /* %a% */; - echo ' -'; - echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(array_pop($this->global->formsStack)) /* %a% */; - - echo ' - - -'; - $form = $this->global->formsStack[] = $this->global->uiControl['myForm'] /* %a% */; - Nette\Bridges\FormsLatte\Runtime::initializeForm($form); - echo ' -global)->getLabelPart())->attributes() /* %a% */; - echo '>'; - echo $ʟ_elem->getHtml() /* %a% */; - echo ' -global)->getControlPart())->attributes() /* %a% */; - echo '> -'; - array_pop($this->global->formsStack) /* %a% */; -%A% diff --git a/tests/Forms.Latte3/n-name.form.phpt b/tests/Forms.Latte3/n-name.form.phpt deleted file mode 100644 index 1e62afa48..000000000 --- a/tests/Forms.Latte3/n-name.form.phpt +++ /dev/null @@ -1,53 +0,0 @@ -setLoader(new Latte\Loaders\StringLoader); -$latte->addExtension(new FormsExtension); - -Assert::match( - <<<'XX' - %A% - $form = $this->global->formsStack[] = $this->global->uiControl['foo'] /* %a% */; - Nette\Bridges\FormsLatte\Runtime::initializeForm($form); - echo 'global->formsStack), [], false) /* %a% */; - echo '>'; - echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(end($this->global->formsStack), false) /* %a% */; - echo ''; - array_pop($this->global->formsStack); - %A% - XX, - $latte->compile('
'), -); - - -Assert::match( - <<<'XX' - %A% - $form = $this->global->formsStack[] = $this->global->uiControl['foo'] /* %a% */; - Nette\Bridges\FormsLatte\Runtime::initializeForm($form); - %a% - if (0) /* %a% */ { - %A% - echo Nette\Bridges\FormsLatte\Runtime::renderFormBegin(end($this->global->formsStack), [], false) /* %a% */; - echo '>'; - %A% - echo Nette\Bridges\FormsLatte\Runtime::renderFormEnd(end($this->global->formsStack), false) /* %a% */; - %a% - array_pop($this->global->formsStack); - %A% - XX, - $latte->compile('
'), -); diff --git a/tests/Forms.Latte3/templates/forms.button.latte b/tests/Forms.Latte3/templates/forms.button.latte deleted file mode 100644 index 8e9969b37..000000000 --- a/tests/Forms.Latte3/templates/forms.button.latte +++ /dev/null @@ -1,9 +0,0 @@ -
- - - - -