I've found it easy to skip some tmpl vars in one pass by giving them a name
not recognized by H::T.
Then do a search/replace on the output of the first pass that substitutes
the real H::T tags back in.

You can mix and match H::T tags with ones that you want left alone in the
first pass something like this -

.
.
.
<body bgcolor="<TMPL_VAR NAME=bg_color>">

Welcome <my_VAR NAME=first_name>
.
.
.

Then in the first pass code you'd set only the vars you need to -

$template->param(       bg_color => "#ffffff" );

my $output = $template->output;

## Replace temporary tags with HTML::Temlate tags 
#
$output =~ s/my_VAR/TMPL_VAR/g;

(at this point I usually write the new, mostly replaced template out to
file)

print $fh $output;


In the first pass, only the bgcolor is set.
The output then has the psuedo tags (my_VAR's) replaced to be handled in the
next pass.

I do this all the time to make template pages as fast as possible for the
end user. 
I can build group specific pages that are flexible but not burden the end
user with 
all the replacements that could be accomplished by a one-time page
generation.

The end-user app would use the template that is output by the first pass and
only 
need to replace user-specific data.

Steve

Steve Ragan
Sr. Internet Developer
Internet Services Division
Bernard C. Harris Publishing Co., Inc.
2500 Westchester Ave.
Purchase, NY  10577
(914) 641-3948
[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>



-----Original Message-----
From: Sam Tregar [mailto:[EMAIL PROTECTED]]
Sent: Sunday, December 16, 2001 1:52 PM
To: Francesco Martelli - HalNet
Cc: [EMAIL PROTECTED]
Subject: Re: [htmltmpl] <tmpl_skip>


On Thu, 13 Dec 2001, Francesco Martelli - HalNet wrote:

> simply we need a "skip parsing tag".
> how can we do it? reading the following lines.

I think I'd rather see a solution that used filter, if possible.  I think
it could be done easily enough by translating <tmpl_*> inside the
<tmpl_skip> block to something else (<_tmpl_*>, for example).  Then use a
second filter on the next run that translates the <_tmpl_*> back to
<tmpl_*>.

If using two filters is too ugly I can imagine a more ambitious design
that works like HTML::Template::Expr and transforms <tmpl_skip> blocks
into single <tmpl_var>s that then get filled in with the real text in the
<tmpl_skip>.

I don't think this is right for the main module.  It adds complexity to
the template syntax with a very slim gain in utility.

-sam



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to