| HTML-Template-Compiled documentation | Contained in the HTML-Template-Compiled distribution. |
HTML::Template::Compiled::Lazy - Lazy Loading for HTML::Template::Compiled
use HTML::Template::Compiled::Lazy;
my $htcl = HTML::Template::Compiled::Lazy->new(
# usual parameters for HTML::Template::Compiled
);
$htcl->param(...);
# file wasn't compiled yet
print $htcl->output; # now compile and output!
This class does not compile templates before calling output().
This includes TMPL_INCLUDEs. This can be useful in CGI environments.
If your template has got a lot of includes HTML::Template::Compiled will
compile all of them, even if they aren't needed because they are never
reached (in a TMPL_IF, for example).
HTML::Template::Compiled::Lazy also won't complain if the file does
not exist - it will complain when you call output(), though.
| HTML-Template-Compiled documentation | Contained in the HTML-Template-Compiled distribution. |
package HTML::Template::Compiled::Lazy; # $Id: Lazy.pm 693 2006-10-04 20:29:26Z tinita $ use strict; use warnings; our $VERSION = "0.01"; use base 'HTML::Template::Compiled'; sub from_scratch { my ($self) = @_; # dummy method. wait until real compilation until output(). return $self; } sub compile_early { 0 } sub query { my ( $self, @args ) = @_; my $perl = $self->get_perl; unless ($perl) { $self = $self->SUPER::from_scratch(); } $self->SUPER::query(@args); } sub output { my ( $self, @args ) = @_; my $perl = $self->get_perl; unless ($perl) { $self = $self->SUPER::from_scratch(); } $self->SUPER::output(@args); } sub get_code { my ($self) = @_; my $perl = $self->get_perl; unless ($perl) { $self = $self->SUPER::from_scratch; $perl = $self->get_perl; } return $perl; } 1; __END__