From 567c0d7c4b7dec742d398ea6df68fc34a0c2649c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Wed, 21 Jul 2010 17:35:29 +0200 Subject: [PATCH] Template Objekt cachen. --- SL/Form.pm | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/SL/Form.pm b/SL/Form.pm index 63182424d..4a5ff406b 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -847,28 +847,42 @@ sub parse_html_template { $additional_params ||= { }; - $file = $self->_prepare_html_template($file, $additional_params); - - my $template = Template->new({ 'INTERPOLATE' => 0, - 'EVAL_PERL' => 0, - 'ABSOLUTE' => 1, - 'CACHE_SIZE' => 0, - 'PLUGIN_BASE' => 'SL::Template::Plugin', - 'INCLUDE_PATH' => '.:templates/webpages', - 'COMPILE_EXT' => $main::template_compile_ext, - 'COMPILE_DIR' => $main::template_compile_dir, - }) || die; + my $real_file = $self->_prepare_html_template($file, $additional_params); + my $template = $self->template || $self->init_template; map { $additional_params->{$_} ||= $self->{$_} } keys %{ $self }; my $output; - $template->process($file, $additional_params, \$output) || die $template->error(); + $template->process($real_file, $additional_params, \$output) || die $template->error; $main::lxdebug->leave_sub(); return $output; } +sub init_template { + my $self = shift; + + return if $self->template; + + return $self->template(Template->new({ + 'INTERPOLATE' => 0, + 'EVAL_PERL' => 0, + 'ABSOLUTE' => 1, + 'CACHE_SIZE' => 0, + 'PLUGIN_BASE' => 'SL::Template::Plugin', + 'INCLUDE_PATH' => '.:templates/webpages', + 'COMPILE_EXT' => $main::template_compile_ext, + 'COMPILE_DIR' => $main::template_compile_dir, + })) || die; +} + +sub template { + my $self = shift; + $self->{template_object} = shift if @_; + return $self->{template_object}; +} + sub show_generic_error { $main::lxdebug->enter_sub(); -- 2.20.1