diff --git a/composer.json b/composer.json index 8c0c4bf0b..247bbc888 100644 --- a/composer.json +++ b/composer.json @@ -41,7 +41,7 @@ "nette/di": "<3.2", "nette/forms": "<3.2", "nette/schema": "<1.3", - "latte/latte": "<3.1.5 || >=3.2", + "latte/latte": "<3.1.4 || >=3.2", "tracy/tracy": "<2.12" }, "autoload": { diff --git a/src/Bridges/ApplicationLatte/Nodes/ControlNode.php b/src/Bridges/ApplicationLatte/Nodes/ControlNode.php index 43f9d3926..5bb6f30a5 100644 --- a/src/Bridges/ApplicationLatte/Nodes/ControlNode.php +++ b/src/Bridges/ApplicationLatte/Nodes/ControlNode.php @@ -17,7 +17,7 @@ /** - * {control name[:method] [, params]} + * {control name[:method] [,] [params]} * Renders a component by calling its render() method. */ class ControlNode extends StatementNode @@ -39,7 +39,7 @@ public static function create(Tag $tag): static $node->method = $tag->parser->parseExpression(); } - $tag->parser->consumeCommaBeforeArguments(strict: false); + $stream->tryConsume(','); $start = $stream->getIndex(); $node->args = $tag->parser->parseArguments(); $start -= $stream->getIndex(); diff --git a/tests/Bridges.Latte/{control}.2.phpt b/tests/Bridges.Latte/{control}.2.phpt index e7e85f31c..e9bda2a50 100644 --- a/tests/Bridges.Latte/{control}.2.phpt +++ b/tests/Bridges.Latte/{control}.2.phpt @@ -51,15 +51,15 @@ $latte->renderToString(' {control $name:$name} -{control form, var1} +{control form var1} -{control form, var1, 1, 2} +{control form var1, 1, 2} -{control form, wrap => 5, 1, 2} +{control form wrap => 5, 1, 2} -{control form, [var1 => 5], 1, 2} +{control form [var1 => 5], 1, 2} -{control form, 5, 1, var1: 2} +{control form 5, 1, var1: 2} ', $params); Assert::same([ diff --git a/tests/Bridges.Latte/{control}.commaWarning.phpt b/tests/Bridges.Latte/{control}.commaWarning.phpt deleted file mode 100644 index 1a5dd3281..000000000 --- a/tests/Bridges.Latte/{control}.commaWarning.phpt +++ /dev/null @@ -1,53 +0,0 @@ -setLoader(new Latte\Loaders\StringLoader); -$latte->addExtension(new Nette\Bridges\ApplicationLatte\UIExtension(null)); - - -test('no warning when only the component name is given', function () use ($latte) { - Assert::noError(fn() => $latte->compile('{control form}')); -}); - - -test('no warning when comma separates name and arguments', function () use ($latte) { - Assert::noError(fn() => $latte->compile('{control form, param => 1}')); -}); - - -test('deprecation warning when comma is missing before arguments', function () use ($latte) { - Assert::error( - fn() => $latte->compile('{control form param => 1}'), - E_USER_DEPRECATED, - 'Missing comma before tag arguments on line 1 at column 15.', - ); -}); - - -test('deprecation warning also fires after the :method syntax', function () use ($latte) { - Assert::error( - fn() => $latte->compile('{control form:type param}'), - E_USER_DEPRECATED, - 'Missing comma before tag arguments on line 1 at column 20.', - ); -}); - - -test('a malformed tag emits the deprecation together with the exception', function () use ($latte) { - Assert::error(function () use ($latte) { - Assert::exception( - fn() => $latte->compile('{control form: param => 1}'), - Latte\CompileException::class, - "Unexpected '=>' (on line 1 at column 22)", - ); - }, E_USER_DEPRECATED, 'Missing comma before tag arguments on line 1 at column 22.'); -}); diff --git a/tests/Bridges.Latte/{control}.phpt b/tests/Bridges.Latte/{control}.phpt index dccddaaba..a3c59f235 100644 --- a/tests/Bridges.Latte/{control}.phpt +++ b/tests/Bridges.Latte/{control}.phpt @@ -60,7 +60,7 @@ Assert::match( $ʟ_tmp->renderType('param') /* pos 1:1 */; %A% XX, - $latte->compile('{control form:type, param}'), + $latte->compile('{control form:type param}'), ); Assert::match( @@ -69,7 +69,7 @@ Assert::match( $ʟ_tmp->render(...$params) /* pos 1:1 */; %A% XX, - $latte->compile('{control form, (expand) $params}'), + $latte->compile('{control form (expand) $params}'), ); Assert::match( @@ -78,7 +78,7 @@ Assert::match( $ʟ_tmp->renderType(['param' => 123]) /* pos 1:1 */; %A% XX, - $latte->compile('{control form:type, param => 123}'), + $latte->compile('{control form:type param => 123}'), ); Assert::match(