From: Sven Schöling Date: Wed, 10 Apr 2013 12:26:21 +0000 (+0200) Subject: Erste Version Template Toolkit Druck X-Git-Tag: release-3.1.0beta1~468 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=1b9d0f70b5e58c510ed2ab4337eb0f6512d779ca;p=kivitendo-erp.git Erste Version Template Toolkit Druck --- diff --git a/SL/Template/LaTeX.pm b/SL/Template/LaTeX.pm index a862431d8..5d5008c1f 100644 --- a/SL/Template/LaTeX.pm +++ b/SL/Template/LaTeX.pm @@ -17,7 +17,6 @@ sub new { sub format_string { my ($self, $variable) = @_; - my $form = $self->{"form"}; $variable = $main::locale->quote_special_chars('Template/LaTeX', $variable); @@ -257,6 +256,9 @@ sub _parse_config_option { if ($key eq 'tag-style') { $self->set_tag_style(split(m/\s+/, $value, 2)); } + if ($key eq 'use-template-toolkit') { + $self->set_use_template_toolkit($value); + } } sub _parse_config_lines { @@ -350,7 +352,14 @@ sub parse { $self->{"forced_pagebreaks"} = []; - my $new_contents = $self->parse_block($contents); + my $new_contents; + if ($self->{use_template_toolkit}) { + my $additional_params = $::form; + + $::form->init_template->process(\$contents, $additional_params, \$new_contents) || die $::form->template->error; + } else { + $new_contents = $self->parse_block($contents); + } if (!defined($new_contents)) { $main::lxdebug->leave_sub(); return 0; diff --git a/SL/Template/OpenDocument.pm b/SL/Template/OpenDocument.pm index f9507f9ba..4eed5eae2 100644 --- a/SL/Template/OpenDocument.pm +++ b/SL/Template/OpenDocument.pm @@ -260,7 +260,14 @@ sub parse { $contents =~ s||${new_styles}|; $contents =~ s|[\n\r]||gm; - my $new_contents = $self->parse_block($contents); + my $new_contents; + if ($self->{use_template_toolkit}) { + my $additional_params = $::form; + + $::form->init_template->process(\$contents, $additional_params, \$new_contents) || die $::form->template->error; + } else { + $new_contents = $self->parse_block($contents); + } if (!defined($new_contents)) { $main::lxdebug->leave_sub(); return 0; diff --git a/SL/Template/Plugin/LxLatex.pm b/SL/Template/Plugin/LxLatex.pm new file mode 100644 index 000000000..6a539bdb4 --- /dev/null +++ b/SL/Template/Plugin/LxLatex.pm @@ -0,0 +1,27 @@ +package SL::Template::Plugin::LxLatex; + +use strict; +use parent qw( Template::Plugin ); + +my $cached_instance; + +sub new { + my $class = shift; + + return $cached_instance ||= $class->SUPER::new(@_); +} + +sub init { + my $self = shift; + + $self->install_filter($self->{ _ARGS }->[0] || 'T8'); + + return $self; +} + +sub filter { + my ($self, $text, $args) = @_; + return $::locale->quote_special_chars('Template/LaTeX', $text); +} + +return 'SL::Template::Plugin::LxLatex'; diff --git a/SL/Template/Simple.pm b/SL/Template/Simple.pm index 926ef1f7f..b1f155bf5 100644 --- a/SL/Template/Simple.pm +++ b/SL/Template/Simple.pm @@ -56,6 +56,13 @@ sub set_tag_style { $self->{substitute_vars_re} = "$self->{tag_start_qm}(.+?)$self->{tag_end_qm}"; } +sub set_use_template_toolkit { + my $self = shift; + my $value = shift; + + $self->{use_template_toolkit} = $value; +} + sub cleanup { my ($self) = @_; }