2011/6/17 Christophe COEVOET <s...@notk.org> > ** > Le 17/06/2011 13:23, Sylvain > Com-Océan a écrit : > > Hi, > > I understand how the concept of "traits" aka "Horizontal > Reuse<http://www.twig-project.org/doc/templates.html#horizontal-reuse>" > introduced in Twig 1.1 > > Is it possible to embed a controller with twig and having the same features > ? > > In fact I have a template which embed a controller. > This controller render an action having javascripts. > > The good way is to display the javascript at the end of the html body. > To do that as described in SF2 doc, I have a "javascripts" twig block at > the end of my layout.html.twig (just before </body> > > But I can't manage to add javascript code to this block from the embed > controller template. > > If there was no embed controller but an embed template I would do : > Layout template: > [...] > {% block content %} > {% endblock %} > [...] > {% block javascripts %} > //main javascripts code > {% endblock %} > > Controller template : > {% extends 'ComOceanIntranetBundle::layout.html.twig' %} > [...] > {% block content %} > {% render "MyBundle:myEmbedController:myAction" with > myembed_javascripts %} > {% endblock %} > [...] > {% block javascripts %} > {{ parent() }} > // my controller/action javascripts code > {{ block('myembed_javascripts') }} > {% endblock %} > > myEmbedController template : > [...] > {% block myembed_javascripts %} > //my embed controller/action javascripts code > {% endblock %} > > > This doesn't work because render seems to have "include" behavior and not > "use" behavior. > > Then how to add javascripts to the layout from myEmbedController template > in that situation ? > > Is it possible or it need a concept of Embed controller Horizontal Reuse ? > > Thanks a lot, > > {% render %} puts the content of the response of the subrequest in the > place where the tag is used. There is no way to use a block from the > subrequest in the main request (or the opposite) as you are not sending a > content, not a template and a context. Think that the subrequest could use > another themplating engine, or no template at all. And when using ESI, it is > not rendered at all during the request but an ESI tag is rendered instead > and the corresponding request is done by the proxy cache. > > -- > Christophe | Stof > > - >
Sure, I don't think about that -- Sylvain PAPET Développeur Web Agence de communication Com-Océan www.com-ocean.com -- 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