http://www.perlmonks.org?node_id=1051895


in reply to Template Toolkit WRAPPER variations

Question: Is their any way to make WRAPPER directive interpolate a variable?

Give it a $variable

[%# USAGE tpage --define news_id=all wrapper-macro.tt tpage wrapper-macro.tt -%] [%- BLOCK link -%] <a href="[% action | uri %]/[% newsitem | uri %]">[% content | html %] +</a> [%- END -%] [% SET vink = ( 1 < 2 ) ? 'link' : 'knil'; PROCESS $vink action = 'readnews' newsitem='some' content='Read +Some'; %] [% WRAPPER link action = "readnews" newsitem = news_id %] Read More ... [% END %]
$ tpage wrapper-macro.tt <a href="readnews/some">Read Some</a> <a href="readnews/"> Read More ... </a> $ tpage --define news_id=all wrapper-macro.tt <a href="readnews/some">Read Some</a> <a href="readnews/all"> Read More ... </a>

Replies are listed 'Best First'.
Re^2: Template Toolkit WRAPPER variations
by Anonymous Monk on Sep 02, 2013 at 07:26 UTC