I have a Dwoo template – in example base.html and there is an array $data.
{assign '' 'globalVar'} {* $globalVar empty right now *}
{foreach $data element}
{include '_partial.html'}
{/foreach}
...
<b>{$globalVar}</b>
And here is _partial.html
<p>
{$element.someText}
</p>
{assign "$globalVar $element.someVar" 'globalVar'}
What I want to gain ? In every partial file I want to modify some $globalVar that I want to use after {foreach}.
And here is an important thing – I do not want to do the partial’s {assign} in base.html ! Only in _partial.html.
Is it possible to pass $globalvar to _partial.html by reference so partial file would modify this variable ?
I did not find any real solution – just this workaround:
Dwoo allows to access superglobal vars with
$dwoo.get.variableor$dwoo.post.variableetc..We can get data or also set, so in
_partial.htmlI did something like:In
base.htmlI can access it now with: