smarty-php/smarty

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

Opened this issue · 2 comments

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.

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.

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