Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A compiler plugin that takes unnamed arguments throws "Too many shorthand attributes" in Smarty 5 #1085

Open
gkreitz opened this issue Nov 27, 2024 · 2 comments · May be fixed by #1088
Open

Comments

@gkreitz
Copy link
Contributor

gkreitz commented Nov 27, 2024

The following code runs fine in Smarty 4, but gives a "Too many shorthand attributes" error in Smarty 5:

$this->smarty->registerPlugin(Smarty::PLUGIN_COMPILER, 'testcompilerfunction', 'foo');
$this->assertEquals('1', $this->smarty->fetch('eval:{testcompilerfunction 1}'));

function foo($params, $smarty)
{
    return "<?php echo '{$params[0]}';?>";
}

It's unclear to me if this was an intentional change in Smarty 5, I cannot find any documentation saying so. We unfortunately have a large number of templates relying on the old syntax, so this regression/change is currently a blocker for us moving to Smarty 5.

Somewhat related to #1005, though I interpret that issue as being for function plugins, where the equivalent syntax didn't work in Smarty 4, as far as I know.

@wisskid
Copy link
Contributor

wisskid commented Nov 28, 2024

This was not intentional. I checked and the unit tests only use plugin compilers with named variables, i.e. like {testcompilerfunction var1=1}. This needs to be fixed.

@gkreitz
Copy link
Contributor Author

gkreitz commented Nov 29, 2024

Great that it wasn't intentional! I took a stab at a PR for fixing the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants