diff options
author | tetragon <tetragon@4979c152-3d1c-0410-bac9-87ea11338e46> | 2007-09-15 22:22:41 +0000 |
---|---|---|
committer | tetragon <tetragon@4979c152-3d1c-0410-bac9-87ea11338e46> | 2007-09-15 22:22:41 +0000 |
commit | 46347e4974eb30c4bc212e802b6b45d3163468d1 (patch) | |
tree | 8bb104afa59e5113303d947716a5fcc30aec89ca /LedgerSMB/Template | |
parent | 57dfea7df5e73799e43da21263887ac57aa6383e (diff) |
Adjust templating to allow for no output file.
Due to their nature of the modules, PDF and PS will supply one if needed.
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1612 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'LedgerSMB/Template')
-rwxr-xr-x | LedgerSMB/Template/CSV.pm | 12 | ||||
-rwxr-xr-x | LedgerSMB/Template/HTML.pm | 12 | ||||
-rwxr-xr-x | LedgerSMB/Template/PDF.pm | 2 | ||||
-rwxr-xr-x | LedgerSMB/Template/PS.pm | 2 | ||||
-rwxr-xr-x | LedgerSMB/Template/TXT.pm | 12 |
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; |