}
sub _init {
- my $self = shift;
+ my ($self, %params) = @_;
+
+ $params{myconfig} ||= \%::myconfig;
+ $params{userspath} ||= $::lx_office_conf{paths}->{userspath};
- $self->{source} = shift;
- $self->{form} = shift;
- $self->{myconfig} = shift;
- $self->{userspath} = shift;
+ $self->{$_} = $params{$_} for keys %params;
+
+ $self->{variable_content_types} ||= {};
+ $self->{variable_content_types}->{$_} = lc $self->{variable_content_types}->{$_} for keys %{ $self->{variable_content_types} };
+ $self->{default_variable_content_type} = 'text';
$self->{error} = undef;
$self->{quot_re} = '"';
my $tag_start = shift;
my $tag_end = shift;
+ $self->{custom_tag_style} = 1;
$self->{tag_start} = $tag_start;
$self->{tag_end} = $tag_end;
$self->{tag_start_qm} = quotemeta $tag_start;
$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) = @_;
}
while ($text =~ /$self->{substitute_vars_re}/) {
my ($tag_pos, $tag_len) = ($-[0], $+[0] - $-[0]);
- my ($var, @options) = split(/\s+/, $1);
+ my ($var, @option_list) = split(/\s+/, $1);
+ my %options = map { ($_ => 1) } @option_list;
my $value = $self->_get_loop_variable($var, 0, @indices);
- $value = $self->format_string($value) unless (grep(/^NOESCAPE$/, @options));
+ $value = $form->parse_amount({ numberformat => $::myconfig{output_numberformat} || $::myconfig{numberformat} }, $value) if $options{NOFORMAT};
+ $value = $self->format_string($value, $var) unless $options{NOESCAPE};
substr($text, $tag_pos, $tag_len, $value);
}
}
my $value = $self->_get_loop_variable($var, 0, @indices);
+ $value = scalar(@{ $value }) if (ref($value) || '') eq 'ARRAY';
my $hit = 0;
if ($operator_type) {