Question

Somewhere in the html page that I'm creating I'm inserting a template from other file, that itself contains TT variable definitions. Fragment "specials.htm"

[% specials = 123 %]

But I need to use this variables on a main page before the inclusion of the said fragment. Main page:

<p>Specials are [% specials %]
<!-- some html -->
[% PROCESS specials.htm %]

I've tried to process this inclusion in a BLOCK, then insert this block later - but that doesn't work for some reason:

[% BLOCK specblock %]
  [% PROCESS specials.htm %]
[% END %]

<p>Specials are [% specials %] <!-- No luck! -->

<!-- some html -->

[% INCLUDE specblock %]

Current workaround is - to play with divs and css, so div appears on a page before it's default place by assigning absolute position to it. But that's kind of lame.

Was it helpful?

Solution

If I have understood the problem correctly, how about using an anonymous BLOCK to capture the output of the template fragment into a variable:

[% output = BLOCK %]
    [% PROCESS specials.htm %]
[% END %]

<p>Specials are [% specials %]

<!-- some html -->

[% output %]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top