Imagine you have a branch template (tplA.twig) that includes another
<p>Twig template A</p>
{% set test = "in tpl A" %}
<p>first, variable is: {{ test }}</p>
{% include "tplB.twig" %}
<p>and the variable is: {{ test }}</p>
and included template (tplB.twig)
<div>Content of tpl B</div>
{% set test = "now is tpl B" %}
What is the best way to set / change a variable in an included template and use it in the main template? How to use global variables? Please note: I cannot use blocks and extend, and I do not use Symfony.
Many thanks
EDIT
The real context is a very simple multilingual structure. For the page, I have one main template:
<h1>{{ i18n('mainTitle') }}</h1>
<h2>current language (fr, en): {{ ln }}</h2>
<div>
<div>
<img src="/same/for/all/languages-a.jpg" alt="localized A" />
<span>localized A</span>
</div>
<div>
<img src="/same/for/all/languages-b.jpg" alt="localized B" />
<span>localized B</span>
</div>
</div>
This is a very small website, so I did not create a complex database structure, and I wanted to manage all this material in a template.
, ? , , . - :
{% include ln ~ '/photos-list.twig' %}
, . ( )
, . , ( , )
hudge if . locale - fr, , en, .
, ^^