From: Sven Schöling Date: Wed, 21 Jul 2010 15:35:29 +0000 (+0200) Subject: Template Objekt cachen. X-Git-Tag: release-2.6.2beta1~229 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=567c0d7c4b7dec742d398ea6df68fc34a0c2649c;p=kivitendo-erp.git Template Objekt cachen. --- 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();