summaryrefslogtreecommitdiff
path: root/LedgerSMB/Template
diff options
context:
space:
mode:
Diffstat (limited to 'LedgerSMB/Template')
-rwxr-xr-xLedgerSMB/Template/CSV.pm12
-rwxr-xr-xLedgerSMB/Template/HTML.pm12
-rwxr-xr-xLedgerSMB/Template/PDF.pm2
-rwxr-xr-xLedgerSMB/Template/PS.pm2
-rwxr-xr-xLedgerSMB/Template/TXT.pm12
5 files changed, 31 insertions, 9 deletions
diff --git a/LedgerSMB/Template/CSV.pm b/LedgerSMB/Template/CSV.pm
index 9f494d69..bd06e478 100755
--- a/LedgerSMB/Template/CSV.pm
+++ b/LedgerSMB/Template/CSV.pm
@@ -75,7 +75,13 @@ sub process {
my $parent = shift;
my $cleanvars = shift;
my $template;
+ my $output;
+ if ($parent->{outputfile}) {
+ $output = "$parent->{outputfile}.csv";
+ } else {
+ $output = \$parent->{output};
+ }
$template = Template->new({
INCLUDE_PATH => $parent->{include_path},
START_TAG => quotemeta('<?lsmb'),
@@ -89,7 +95,7 @@ sub process {
get_template($parent->{template}),
{%$cleanvars, %$LedgerSMB::Template::TTI18N::ttfuncs,
'escape' => \&preprocess},
- "$parent->{outputfile}.csv", binmode => ':utf8')) {
+ $output, binmode => ':utf8')) {
throw Error::Simple $template->error();
}
$parent->{mimetype} = 'text/csv';
@@ -97,8 +103,8 @@ sub process {
sub postprocess {
my $parent = shift;
- $parent->{rendered} = "$parent->{outputfile}.csv";
- return "$parent->{outputfile}.csv";
+ $parent->{rendered} = "$parent->{outputfile}.csv" if $parent->{outputfile};
+ return $parent->{rendered};
}
1;
diff --git a/LedgerSMB/Template/HTML.pm b/LedgerSMB/Template/HTML.pm
index 3eb442c8..da9d2e00 100755
--- a/LedgerSMB/Template/HTML.pm
+++ b/LedgerSMB/Template/HTML.pm
@@ -75,7 +75,13 @@ sub process {
my $parent = shift;
my $cleanvars = shift;
my $template;
+ my $output;
+ if ($parent->{outputfile}) {
+ $output = "$parent->{outputfile}.html";
+ } else {
+ $output = \$parent->{output};
+ }
$template = Template->new({
INCLUDE_PATH => $parent->{include_path},
START_TAG => quotemeta('<?lsmb'),
@@ -89,7 +95,7 @@ sub process {
get_template($parent->{template}),
{%$cleanvars, %$LedgerSMB::Template::TTI18N::ttfuncs,
'escape' => \&preprocess},
- "$parent->{outputfile}.html", binmode => ':utf8')) {
+ $output, binmode => ':utf8')) {
throw Error::Simple $template->error();
}
$parent->{mimetype} = 'text/html';
@@ -97,8 +103,8 @@ sub process {
sub postprocess {
my $parent = shift;
- $parent->{rendered} = "$parent->{outputfile}.html";
- return "$parent->{outputfile}.html";
+ $parent->{rendered} = "$parent->{outputfile}.html" if $parent->{outputfile};
+ return $parent->{rendered};
}
1;
diff --git a/LedgerSMB/Template/PDF.pm b/LedgerSMB/Template/PDF.pm
index 557a5d09..617ca41f 100755
--- a/LedgerSMB/Template/PDF.pm
+++ b/LedgerSMB/Template/PDF.pm
@@ -74,6 +74,8 @@ sub process {
my $parent = shift;
my $cleanvars = shift;
my $template;
+ $parent->{outputfile} ||=
+ "${LedgerSMB::Sysconfig::tempdir}/$parent->{template}-output-$$";
$template = Template::Latex->new({
LATEX_FORMAT => 'pdf',
diff --git a/LedgerSMB/Template/PS.pm b/LedgerSMB/Template/PS.pm
index ca80066b..7ab41dc2 100755
--- a/LedgerSMB/Template/PS.pm
+++ b/LedgerSMB/Template/PS.pm
@@ -74,6 +74,8 @@ sub process {
my $parent = shift;
my $cleanvars = shift;
my $template;
+ $parent->{outputfile} ||=
+ "${LedgerSMB::Sysconfig::tempdir}/$parent->{template}-output-$$";
$template = Template::Latex->new({
LATEX_FORMAT => 'ps',
diff --git a/LedgerSMB/Template/TXT.pm b/LedgerSMB/Template/TXT.pm
index 055a6cdd..2d902a39 100755
--- a/LedgerSMB/Template/TXT.pm
+++ b/LedgerSMB/Template/TXT.pm
@@ -56,7 +56,13 @@ sub process {
my $parent = shift;
my $cleanvars = shift;
my $template;
+ my $output;
+ if ($parent->{outputfile}) {
+ $output = "$parent->{outputfile}.txt";
+ } else {
+ $output = \$parent->{output};
+ }
$template = Template->new({
INCLUDE_PATH => $parent->{include_path},
START_TAG => quotemeta('<?lsmb'),
@@ -70,7 +76,7 @@ sub process {
get_template($parent->{template}),
{%$cleanvars, %$LedgerSMB::Template::TTI18N::ttfuncs,
'escape' => \&preprocess},
- "$parent->{outputfile}.txt", binmode => ':utf8')) {
+ $output, binmode => ':utf8')) {
throw Error::Simple $template->error();
}
$parent->{mimetype} = 'text/plain';
@@ -78,8 +84,8 @@ sub process {
sub postprocess {
my $parent = shift;
- $parent->{rendered} = "$parent->{outputfile}.txt";
- return "$parent->{outputfile}.txt";
+ $parent->{rendered} = "$parent->{outputfile}.txt" if $parent->{outputfile};
+ return $parent->{rendered};
}
1;