sub format_string {
my ($self, $variable) = @_;
- my $form = $self->{"form"};
$variable = $main::locale->quote_special_chars('Template/LaTeX', $variable);
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 {
$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;
$contents =~ s|</office:automatic-styles>|${new_styles}</office:automatic-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;
--- /dev/null
+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';
$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) = @_;
}