On 08.07.2011, at 08:12, Lukas Kahwe Smith <m...@pooteeweet.org> wrote:
> On 08.07.2011, at 07:59, Fabien Potencier
> <fabien.potenc...@symfony-project.com> wrote:
>
>> On 7/8/11 12:14 AM, Lukas Kahwe Smith wrote:
>>> Hi,
>>>
>>> Right now when rendering and passing in a scalar/object variable or a
>>> single list, it is necessary to wrap things into an array to give twig a
>>> variable name:
>>>
>>> $this->templating->render($template, array('article' => $article));
>>> $this->templating->render($template, array('article_list' => $articles));
>>>
>>> imho it would be nicer if one could just write:
>>>
>>> $this->templating->render($template, $article);
>>> $this->templating->render($template, $articles);
>>
>> You can do:
>>
>> $this->templating->render($template, compact($article));
>> $this->templating->render($template, compact($articles));
>>
>> or even:
>>
>> $this->templating->render($template, compact($article, $articles));
>
> compact() is nice when you have multiple parameters, but not really if you
> have just one.
>
> i guess i didnt mention how i came to this proposal. the issue is that in
> FOSRestBundle if i set parameters which can either used for html or json/xml
> output it sucks to be forced to wrap everything in an array just to make the
> template engine happy.
>
> my suggestion would solve the issue. but it would imho also be more elegant
> and efficient for the non FOSRestBundle case, which os why i suggested it out
> of this context.
i should note that unless core is changed i will just add code to the
restbundle htmlencoder to check if the parameters are either a non array or a
numerically indexed array and i that case wrap the parameters in an array with
the key "params".
regards
Lukas
--
If you want to report a vulnerability issue on symfony, please send it to
security at symfony-project.com
You received this message because you are subscribed to the Google
Groups "symfony developers" group.
To post to this group, send email to symfony-devs@googlegroups.com
To unsubscribe from this group, send email to
symfony-devs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-devs?hl=en