saskaqueer has asked for the wisdom of the Perl Monks concerning the following question:
There is a bug in Template -- ok, supposidly this is actually a bug in perl, but I am sure that the author of Template could have worked around the issue. Basically, you cannot use the 'Interpolate' feature of the module when loading a template larger than ~30k; if you do, perl will dump core, segfault, or do something of the sort.
Here's the example that I have in which Template fails:
my $TMPL = Template->new( { DELIMITER => ';', INCLUDE_PATH => 'C:/Apache2/sites/foobar/template', INTERPOLATE => 1 } ); $TMPL->process( \*DATA, { screen => qw(screen1 screen2)[rand 2] } ); __END__ [% INCLUDE primary/html_head.tmpl %] [% INCLUDE "$screen" %] [% INCLUDE primary/html_foot.tmpl %] [% BLOCK screen1 %] This is screen #1. [% END %] [% BLOCK screen2 %] This is screen #2. [% END %]
Of course, it is possible to work around this in this fashion:
__END__ [% INCLUDE primary/html_head.tmpl %] [% IF screen == 'screen1' %] [% INCLUDE screen1 %] [% ELSIF screen == 'screen2' %] [% INCLUDE screen2 %] [% END %] [% INCLUDE primary/html_foot.tmpl %]
But if I have several screens, this can get very annoying to code and is definitely ugly. Can anybody think of a way to get around this alternative of mine?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Interpolate within Template
by edoc (Chaplain) on Jan 13, 2005 at 01:36 UTC | |
by saskaqueer (Friar) on Jan 13, 2005 at 05:06 UTC | |
|
Re: Interpolate within Template
by Tanktalus (Canon) on Jan 12, 2005 at 18:05 UTC |