symfony2 - twig - how to render a twig template from inside a twig template

后端 未结 3 492
醉酒成梦
醉酒成梦 2021-02-05 08:53

I have a xxx.html.twig file which shows a page, but when I want to refresh the page with different data and just update it with new data, I have a select and a submit button for

3条回答
  •  攒了一身酷
    2021-02-05 09:31

    I think some parts are depricated here. To make the include work in latest Symfony 3.1.10, I solved it like this:

    {% extends 'base.html.twig' %}
    {% block body %}
        {{ include('AppBundle:Default:inner_content.html.twig') }}
    {% endblock %}
    

    Note: include() with parentheses. Then all the variables are included from the parent template. If you like to restrict some variables in the child template, you use with ... only (look over)

提交回复
热议问题