summaryrefslogtreecommitdiff
path: root/LedgerSMB/Template
diff options
context:
space:
mode:
authortetragon <tetragon@4979c152-3d1c-0410-bac9-87ea11338e46>2007-06-05 01:05:12 +0000
committertetragon <tetragon@4979c152-3d1c-0410-bac9-87ea11338e46>2007-06-05 01:05:12 +0000
commit501ac60d3a4a6d438ba93495d6be379afc5ec44a (patch)
tree2392ceddd558a40bc4b96982cd06dd722bbd7a21 /LedgerSMB/Template
parent6fb2b8d80595bde410e71deab19474596287eba4 (diff)
More tests and PDF support now works with XeTeX and preliminary escaping
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1255 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'LedgerSMB/Template')
-rwxr-xr-xLedgerSMB/Template/PDF.pm23
-rwxr-xr-xLedgerSMB/Template/TXT.pm9
2 files changed, 22 insertions, 10 deletions
diff --git a/LedgerSMB/Template/PDF.pm b/LedgerSMB/Template/PDF.pm
index 7286b917..f201b11d 100755
--- a/LedgerSMB/Template/PDF.pm
+++ b/LedgerSMB/Template/PDF.pm
@@ -45,12 +45,27 @@ sub get_template {
my $name = shift;
return "${name}.tex";
}
+
sub preprocess {
my $rawvars = shift;
my $vars;
my $type = ref $rawvars;
- #XXX Fix escaping
- return $rawvars;
+
+ if ($type eq 'ARRAY') {
+ for (@{$rawvars}) {
+ push @{$vars}, preprocess($_);
+ }
+ } elsif ($type eq 'HASH') {
+ for ( keys %{$rawvars} ) {
+ $vars->{$_} = preprocess($rawvars->{$_});
+ }
+ } else {
+ #XXX Fix escaping
+ $rawvars =~ s/([&\$\\_<>~^#\%\{\}])/\\$1/g;
+ $rawvars =~ s/"(.*)"/``$1''/gs;
+ return $rawvars;
+ }
+ return $vars;
}
sub process {
@@ -63,12 +78,12 @@ sub process {
INCLUDE_PATH => $parent->{include_path},
START_TAG => quotemeta('<?lsmb'),
END_TAG => quotemeta('?>'),
- DELIMITER => ';',
+ DELIMITER => ';'
}) || throw Error::Simple Template::Latex->error();
if (not $template->process(
get_template($parent->{template}),
- $cleanvars, "$parent->{outputfile}.pdf", binmode => ':utf8')) {
+ $cleanvars, "$parent->{outputfile}.pdf", binmode => 1)) {
throw Error::Simple $template->error();
}
$parent->{mimetype} = 'application/pdf';
diff --git a/LedgerSMB/Template/TXT.pm b/LedgerSMB/Template/TXT.pm
index d7a76430..40d6edb5 100755
--- a/LedgerSMB/Template/TXT.pm
+++ b/LedgerSMB/Template/TXT.pm
@@ -13,7 +13,7 @@ Returns the appropriate template filename for this format.
=item preprocess ($vars)
-Currently does nothing.
+Returns $vars.
=item process ($parent, $cleanvars)
@@ -21,7 +21,7 @@ Processes the template for text.
=item postprocess ($parent)
-Currently does nothing.
+Returns the output filename.
=back
@@ -48,10 +48,7 @@ sub get_template {
sub preprocess {
my $rawvars = shift;
- my $vars;
- my $type = ref $rawvars;
-
- return $vars;
+ return $rawvars;
}
sub process {