I have a template twig in html for example:
<p>Test document</p>
<p>However</p>
I would like to replace the word ‘Test’ in the include template.
{% include '@template/testing' %}
Is there some solution to replace the word in the include statement?
I tried to use replace inside the {% include '@template/testing' %}
but I don`t how to start it.
2
Answers
I found a solution
Take a closer look at the docs:
That means you can set a variable in the current template and reference the variable in the included template, where you can also define a default value.
template/testing:
current template:
Or pass it directly in one line:
Same, but included template will not have access to the variables of the active context:
Any of these methods will render:
Here is a good explanation for all this.