Re: [htmltmpl] how can I insert non-printing comments in templates?
Brought to you by:
samtregar
From: Puneet K. <pk...@ei...> - 2003-10-26 17:06:56
|
a minor correction for the benefit of others who might use this trick -- > > On Sunday, October 26, 2003, at 10:30 AM, Cees Hek wrote: > >> .. >> >> or you could write a simple filter that strips out all your comments >> when you >> load the template: >> >> my $filter = sub { >> my $text_ref = shift; >> $$text_ref =~ s/\<\<\!\-\-.*?\-\-\>\>//g; >> }; >> >> my $template = HTML::Template->new(filename => $template_file, >> filter => $filter); >> >> no need to escape all those html chars. The following works for me -- # create new template my $template = HTML::Template->new( filename => $template, global_vars => 1, loop_context_vars => 1, filter => sub { $$ =~ s/<!--#.*?-->//g; } ); |