noiselabs / SmartyBundle

Smarty3 template engine bundle for Symfony
http://smartybundle.readthedocs.io/
GNU Lesser General Public License v3.0
51 stars 36 forks source link

{render} tag doesn't work like it should #14

Closed Bersman closed 12 years ago

Bersman commented 12 years ago

Hello,

im using {render menutype='mobile'}WebsiteBundle:Menu:list{/render} Now im getting an error: "MenuController::listAction()" requires that you provide a value for the "$menutype" argument (because there is no default value or because there is a non optional argument after this one)"

Between step 8 and 9 im losing the parameters. "at ActionsHelper ->render ('WebsiteBundle:Menu:list', array(), array())

in ***/vendor/bundles/NoiseLabs/Bundle/SmartyBundle/Extension/ActionsExtension.php at line 80 -+ at ActionsExtension ->renderAction (array('menuype' => 'other'), 'WebsiteBundle:Menu:list', object(Smarty_Internal_Template), false) "

When I go to the bundles/NoiseLabs/Bundle/SmartyBundle/Extension/ActionsExtension.php at line 80 I see that attributes and options are merged with parameters and are set as an empty array.

The problem is that the listAction listen to those to. A short 'fix' is to put 'attributes => $parameters

But that is not a nice fix. Do you known a better one ?

Bersman commented 12 years ago

Other solution that I use is: Line 76: 'attributes' => !array_key_exists('attributes', $parameters) ? $parameters : $parameters['attributes'],

vitorbrandao commented 12 years ago

Thanks for reporting this issue and thanks for alerting me via twitter. I'll try to reproduce this and provide a fix.

vitorbrandao commented 12 years ago

@Bersman please check if the latest commit fixes your problem. The syntax for the render function has changed. The documentation was updated to reflect this changes. Usage examples:

Using a block function:

{render attributes=['min'=>1,'max'=>3]}AcmeArticleBundle:Article:recentArticles{/render}

Using a modifier:

{'AcmeArticleBundle:Article:recentArticles'|render:['min'=>1,'max'=>3]}
Bersman commented 12 years ago

I'm on holiday from work. So can't check. I will @ august.

vitorbrandao commented 12 years ago

@Bersman OK, have a nice holiday!

Bersman commented 12 years ago

Its working :) Thank you for fixing it.