[Templates] PROCESS directive and variables

[prev] [thread] [next] [Date index for 2004/11/13]

From: Dmitry Katsubo
Subject: [Templates] PROCESS directive and variables
Date: 15:30 on 13 Nov 2004
Hello, all users and creators of Template Toolkit!

I am using TT v2.14.

I have problems using the PROCESS (and others of this kind) directive.
Generally, I want to do the following tricky processing with variable
interpolation:

=== cut ===
[% PROCESS 'tables/headers/' _ (param.body_tmpl || 'simple_body') _ '.html.tmpl' %]
=== cut ===

but I found out, that even the following does not work:

=== cut ===
[% PROCESS 'tables/headers/' _ param.body_tmpl _ '.html.tmpl' %]
=== cut ===

The same issue I found in the letter for TT v2.10:

http://template-toolkit.org/pipermail/templates/2003-September/005065.html

And in this example, it tries to treat the part of string as a hash:

=== cut ===
[% PROCESS "tables/headers/simple_limit_header.html.tmpl" %]
[% PROCESS 'tables/headers/simple_limit_header.html.tmpl' %]

Can't use string ("tables/headers/simple_limit_head") as a HASH ref while
"strict refs" in use at
/usr/local/lib/perl5/site_perl/5.8.0/i386-linux/Template/Provider.pm line 690.
=== cut ===

As for me, I do not understand, why PROCESS is a bit special. In TT the
statements are treated as variables (e.g [% var %]), and strings are enclosed in
quotes... But not in PROCESS. For it a statement is a string, and for variable I
should write a $ sign and cannot use the string interpolation. Of course, it is
impossible to change something now, when TT is very popular and running on many
sites, but maybe someone can help me to create a patch for TT grammar parser,
what will treat:

[% SET param.body_tmpl = 'simple_body' %]

Example                                    | Action
-------------------------------------------+---------------------------------------
[% PROCESS param.body_tmpl %]              | Processing the file 'simple_body'
[% PROCESS param.body_tmpl _ '.tmpl' %]    | Processing the file 'simple_body.tmpl'
[% PROCESS "${param.body_tmpl}.tmpl" %]    | Processing the file 'simple_body.tmpl'
[% PROCESS 'other.tmpl' IF param.doit %]   | Processing the file 'other.tmpl' if param.doit is defined

Thanks a lot.


_______________________________________________
templates mailing list
templates@xxxxxxxxxxxxxxxx.xxx
http://lists.template-toolkit.org/mailman/listinfo/templates

[Templates] PROCESS directive and variables
Dmitry Katsubo 15:30 on 13 Nov 2004

Re: [Templates] PROCESS directive and variables
Andy Wardley 19:30 on 13 Nov 2004

Re: [Templates] PROCESS directive and variables
Dmitry Katsubo 21:42 on 13 Nov 2004

Re: [Templates] PROCESS directive and variables
Darren Chamberlain 14:33 on 15 Nov 2004

Generated at 08:55 on 15 Mar 2005 by mariachi v0.52