I would like to pass the output of the included Twig template to another Twig template as a parameter, for example:
{% include 'MyBundle:Default:tpl1.html.twig' with {'item': include 'MyBundle:Default:tpl2.html.twig'} %}
Unfortunately, this does not work, because the syntax is invalid. Any ideas on how to embed templates like this / store the output of the included template in a variable? Or is there an alternative way to accomplish what I want to do? I was thinking about defining blocks in an included template, but it seems not possible to rewrite them from an "external" template ...
source share