NicolaPez
NicolaPez

Reputation: 587

How to extends dynamic template in Twig?

i need to extends different base template in twig. this is possible? in my code i use dinamically render template with a controller like this

{{ render(controller('AppBundle:Default:menuManager')) }}

in that controller i use one action to choose the right template to render in my page, and this work fine. But in this case is different: i what change my base default (so i presume to extends it, right?) but i don't know how do this. Something like this?

{{ extends(controller('AppBundle:Default:baseManager')) }}

But this code don't work. Is possible? There is a different way? Thanks

Upvotes: 1

Views: 808

Answers (1)

Le Menach Florian
Le Menach Florian

Reputation: 462

This depends on the conditions for choosing the template base but you can use a twig extension. I use that in one project :

{% extends app.request.host | switchBaseTemplate %}

In this example, I use the host for the condition. You can then write a twig extension easily, as explained here : http://symfony.com/doc/current/templating/twig_extension.html

Have good dev.

Upvotes: 2

Related Questions