Re: [Templates] setting macro parameters at run time
[prev]
[thread]
[next]
[Date index for 2004/06/18]
Jens Porup wrote:
> Is there a way to set the parameters to a macro at run time?
>
> So I have a macro like so:
>
> [%- MACRO foo(bar,baz) BLOCK -%]
> [%# do some stuff here %]
> [%- END -%]
>
> But I want to call the macro like so:
>
> <td>foo(bar="blah", baz= "blah" _ [% ANOTHER_VARIABLE %])</td>
I think you'd want to do this:
[% tempbaz = "blah" _ ANOTHER_VARIABLE %]
<td>[% foo(bar="blah", baz=tempbaz) %]</td>
The parser doesn't much like inline string construction in calls, you
normally need to build the argument first in a single variable and then
pass that.
> But I get error message like so:
>
> file error - parse error - myfile.tt2 line 46: unexpected token (%)
> [% filter("rt=COD","Collection Occasions<a href=\"[% PUBLISH_DESTINATION %]
>
> Is there a workaround for this problem? Or am I just doing it wrong?
You almost never want to nest your tags like this:
[% somthing ... [% variable %] ... %]
instead you mostly want to refer to the variable directly
[% somthing ... variable ... %]
or indirectly
[% somthing ... $variable ... %]
HTH
--mark
_______________________________________________
templates mailing list
templates@xxxxxxxxxxxxxxxx.xxx
http://lists.template-toolkit.org/mailman/listinfo/templates
 |
 |
Re: [Templates] setting macro parameters at run time
Mark Mills 05:52 on 18 Jun 2004
|