summaryrefslogtreecommitdiff
path: root/LedgerSMB
diff options
context:
space:
mode:
Diffstat (limited to 'LedgerSMB')
-rwxr-xr-xLedgerSMB/Template.pm3
-rwxr-xr-xLedgerSMB/Template/CSV.pm10
-rwxr-xr-xLedgerSMB/Template/HTML.pm10
-rwxr-xr-xLedgerSMB/Template/PDF.pm10
-rwxr-xr-xLedgerSMB/Template/PS.pm10
-rwxr-xr-xLedgerSMB/Template/TXT.pm10
6 files changed, 47 insertions, 6 deletions
diff --git a/LedgerSMB/Template.pm b/LedgerSMB/Template.pm
index 1f578583..e0979881 100755
--- a/LedgerSMB/Template.pm
+++ b/LedgerSMB/Template.pm
@@ -19,7 +19,8 @@ This command instantiates a new template:
=item template
-The name of the template file to be processed.
+The template to be processed. This can either be a reference to the template
+in string form or the name of the file that is the template to be processed.
=item format
diff --git a/LedgerSMB/Template/CSV.pm b/LedgerSMB/Template/CSV.pm
index bd06e478..9700a18a 100755
--- a/LedgerSMB/Template/CSV.pm
+++ b/LedgerSMB/Template/CSV.pm
@@ -75,6 +75,7 @@ sub process {
my $parent = shift;
my $cleanvars = shift;
my $template;
+ my $source;
my $output;
if ($parent->{outputfile}) {
@@ -82,6 +83,13 @@ sub process {
} else {
$output = \$parent->{output};
}
+ if (ref $parent->{template} eq 'SCALAR') {
+ $source = $parent->{template};
+ } elsif (ref $parent->{template} eq 'ARRAY') {
+ $source = join "\n", @{$parent->{template}};
+ } else {
+ $source = get_template($parent->{template});
+ }
$template = Template->new({
INCLUDE_PATH => $parent->{include_path},
START_TAG => quotemeta('<?lsmb'),
@@ -92,7 +100,7 @@ sub process {
}) || throw Error::Simple Template->error();
if (not $template->process(
- get_template($parent->{template}),
+ $source,
{%$cleanvars, %$LedgerSMB::Template::TTI18N::ttfuncs,
'escape' => \&preprocess},
$output, binmode => ':utf8')) {
diff --git a/LedgerSMB/Template/HTML.pm b/LedgerSMB/Template/HTML.pm
index da9d2e00..cb9bd2fe 100755
--- a/LedgerSMB/Template/HTML.pm
+++ b/LedgerSMB/Template/HTML.pm
@@ -76,12 +76,20 @@ sub process {
my $cleanvars = shift;
my $template;
my $output;
+ my $source;
if ($parent->{outputfile}) {
$output = "$parent->{outputfile}.html";
} else {
$output = \$parent->{output};
}
+ if (ref $parent->{template} eq 'SCALAR') {
+ $source = $parent->{template};
+ } elsif (ref $parent->{template} eq 'ARRAY') {
+ $source = join "\n", @{$parent->{template}};
+ } else {
+ $source = get_template($parent->{template});
+ }
$template = Template->new({
INCLUDE_PATH => $parent->{include_path},
START_TAG => quotemeta('<?lsmb'),
@@ -92,7 +100,7 @@ sub process {
DEBUG_FORMAT => '',
}) || throw Error::Simple Template->error();
if (not $template->process(
- get_template($parent->{template}),
+ $source,
{%$cleanvars, %$LedgerSMB::Template::TTI18N::ttfuncs,
'escape' => \&preprocess},
$output, binmode => ':utf8')) {
diff --git a/LedgerSMB/Template/PDF.pm b/LedgerSMB/Template/PDF.pm
index 617ca41f..ef7ca519 100755
--- a/LedgerSMB/Template/PDF.pm
+++ b/LedgerSMB/Template/PDF.pm
@@ -74,9 +74,17 @@ sub process {
my $parent = shift;
my $cleanvars = shift;
my $template;
+ my $source;
$parent->{outputfile} ||=
"${LedgerSMB::Sysconfig::tempdir}/$parent->{template}-output-$$";
+ if (ref $parent->{template} eq 'SCALAR') {
+ $source = $parent->{template};
+ } elsif (ref $parent->{template} eq 'ARRAY') {
+ $source = join "\n", @{$parent->{template}};
+ } else {
+ $source = get_template($parent->{template});
+ }
$template = Template::Latex->new({
LATEX_FORMAT => 'pdf',
INCLUDE_PATH => $parent->{include_path},
@@ -88,7 +96,7 @@ sub process {
}) || throw Error::Simple Template::Latex->error();
if (not $template->process(
- get_template($parent->{template}),
+ $source,
{%$cleanvars, %$LedgerSMB::Template::TTI18N::ttfuncs,
'escape' => \&preprocess},
"$parent->{outputfile}.pdf", binmode => 1)) {
diff --git a/LedgerSMB/Template/PS.pm b/LedgerSMB/Template/PS.pm
index 7ab41dc2..fc732590 100755
--- a/LedgerSMB/Template/PS.pm
+++ b/LedgerSMB/Template/PS.pm
@@ -74,9 +74,17 @@ sub process {
my $parent = shift;
my $cleanvars = shift;
my $template;
+ my $source;
$parent->{outputfile} ||=
"${LedgerSMB::Sysconfig::tempdir}/$parent->{template}-output-$$";
+ if (ref $parent->{template} eq 'SCALAR') {
+ $source = $parent->{template};
+ } elsif (ref $parent->{template} eq 'ARRAY') {
+ $source = join "\n", @{$parent->{template}};
+ } else {
+ $source = get_template($parent->{template});
+ }
$template = Template::Latex->new({
LATEX_FORMAT => 'ps',
INCLUDE_PATH => $parent->{include_path},
@@ -88,7 +96,7 @@ sub process {
}) || throw Error::Simple Template::Latex->error();
if (not $template->process(
- get_template($parent->{template}),
+ $source,
{%$cleanvars, %$LedgerSMB::Template::TTI18N::ttfuncs,
'escape' => \&preprocess},
"$parent->{outputfile}.ps", binmode => 1)) {
diff --git a/LedgerSMB/Template/TXT.pm b/LedgerSMB/Template/TXT.pm
index 2d902a39..d6fa3e4b 100755
--- a/LedgerSMB/Template/TXT.pm
+++ b/LedgerSMB/Template/TXT.pm
@@ -56,6 +56,7 @@ sub process {
my $parent = shift;
my $cleanvars = shift;
my $template;
+ my $source;
my $output;
if ($parent->{outputfile}) {
@@ -63,6 +64,13 @@ sub process {
} else {
$output = \$parent->{output};
}
+ if (ref $parent->{template} eq 'SCALAR') {
+ $source = $parent->{template};
+ } elsif (ref $parent->{template} eq 'ARRAY') {
+ $source = join "\n", @{$parent->{template}};
+ } else {
+ $source = get_template($parent->{template});
+ }
$template = Template->new({
INCLUDE_PATH => $parent->{include_path},
START_TAG => quotemeta('<?lsmb'),
@@ -73,7 +81,7 @@ sub process {
}) || throw Error::Simple Template->error();
if (not $template->process(
- get_template($parent->{template}),
+ $source,
{%$cleanvars, %$LedgerSMB::Template::TTI18N::ttfuncs,
'escape' => \&preprocess},
$output, binmode => ':utf8')) {