Re: why this substitution is not working?
Dave Cross <[email protected]> Fri, 15 Aug 2014 19:38:36 +0100
| Newsgroups | gmane.comp.lang.perl.modules.template-toolkit |
|---|---|
| Message-ID | <[email protected]> |
On 15/08/14 19:22, Rajeev Prasad wrote:
>
> calling script code snippet:
>
> $vars = {
> userl => $userid
> };
>
> my $tt = Template->new();
> $tt->process($vars)|| die $tt->error();
>
> the template....
> [% IF userl == 'ABC' %]
> [% INCLUDE myfile.ABC %]
> [% ELSIF userl == 'DEF' %]
> [% INCLUDE myfile.DEF %]
> [% END %]
>
> it is working, but it is a long list so i want to change it to:
>
> [% INCLUDE myfile.[% userl %] %]
>
> THIS is not working. can someone tell me why, pl?
It's not working because you can't embed directives within directives.
You want this:
[% INCLUDE "myfile.$userl" %]
Cheers,
Dave...