Pass include path from variable with Twig? -


i need include child-1.twig , child-2.twig in component.twig, , include component.twig in page.twig.

in page.twig:

{% set items  = [   '{% include "child-1.twig" %}',   '{% include "child-2.twig" %}' ] %}  {% include "component.twig" items %} 

in component.twig:

<div class="component">   {% item in items %}     {{ item }}   {% endfor %} </div> 

the complexity comes fact cant modify component.twig, page.twig. code above work if {% include "child-1.twig" %} , {% include "child-2.twig" %} rendered instead printed onto page string of text.

can similar approach make child include run?

can suggest add empty block in file (component.twig)

{% block includes %}{% endblock %} 

then able this:

{% embed "component.twig" items %}     {% block includes %}         {% include "child-1.twig" %}         {% include "child-2.twig" %}     {% endblock %} {% endembed %} 

Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -