Skip to content

Revert "ControlNode: deprecate missing comma before arguments" - #376

Closed
petrparolek wants to merge 1 commit into
nette:masterfrom
petrparolek:petrparolek-patch-1
Closed

petrparolek wants to merge 1 commit into
nette:masterfrom
petrparolek:petrparolek-patch-1

Conversation

@petrparolek

@petrparolek petrparolek commented Nov 6, 2026 •

Copy link
Copy Markdown
  • bug fix
  • BC break? no

This reverts commit 1d1ca9f. In v3.3.1 is not logical and not intuitive very big BC break

example code:

{control poll 1, 'foo'}

@dg

dg commented Nov 7, 2026 •

Copy link
Copy Markdown
Member

Thanks, Petr. You're right that this hurts, and part of the blame is ours: the documentation still shows {control poll $id, $message} without the comma, so anyone who followed it now gets the deprecation, and with Tracy's strict mode in development it shows up as a BlueScreen. I'll fix the docs.

But I want to keep the deprecation. It isn't a BC break: the template still compiles to exactly the same code, and the fix is just adding the comma:

{control poll, 1, 'foo'}

The reason is that without the comma the tag is ambiguous, and in some cases it silently compiles to something else. In Latte, just like in PHP, whitespace inside an expression means nothing: $a -1 is the same as $a - 1, and $f ($x) is a call just like $f($x). So a space can't separate the component from its arguments. The method after the colon and a component name given as a variable are full expressions, so whatever follows sticks to them:

{control cart:small -1}     {* method name 'render' . 'small' - 1, a TypeError instead of renderSmall(-1) *}
{control poll:type [1]}     {* method name from the constant type[1] instead of renderType([1]) *}
{control $comp ($x)}        {* calls $comp($x) and renders without arguments *}

With the comma, all of these work as intended. Since it's impossible to tell from the spacing which form works and which doesn't, the comma is the only spelling that is always correct. {form}, {input} and {label} in nette/forms already deprecate the missing comma the same way, and {control} now follows them. It should have been in 3.3.0 already; I left it out by mistake, which is why it showed up in a patch release.

To make the switch painless, I've written a script that adds the missing commas to your templates. It inserts a comma only where the template compiles to exactly the same code as before, so it can't change what a template does, and it lists the tags where a comma would change the meaning for a manual check. Run php latte-comma.php --dry-run app first to see what it would change.

So I'm closing this, but thanks for raising it.

@dg dg closed this Nov 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants