smarty-php / smarty-php/smarty
A compiler plugin that takes unnamed arguments throws "Too many shorthand attributes" in Smarty 5
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 2.3k
- Forks
- 709
- PR merge metrics
- No merged PRs in 30d
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the registerPlugin(... PLUGIN_COMPILER ...) and fetch('eval:{testcompilerfunction 1}') reproduction in the issue. Trace Smarty 5's handling of unnamed compiler-plugin arguments and compare it with Smarty 4. Done means the example returns '1' without the "Too many shorthand attributes" error, with regression coverage for the compatibility behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100