summaryrefslogtreecommitdiff
path: root/LedgerSMB
diff options
context:
space:
mode:
authortetragon <tetragon@4979c152-3d1c-0410-bac9-87ea11338e46>2007-09-13 17:45:30 +0000
committertetragon <tetragon@4979c152-3d1c-0410-bac9-87ea11338e46>2007-09-13 17:45:30 +0000
commit576020a9432cba748ade22242be42e513f49b67f (patch)
treeaa10f040d59cac2178f20fc30a3b0c1158a513f0 /LedgerSMB
parent02d0ce186cfc17daba79f9c63fb0fe6061e9a766 (diff)
Adding a debug flag
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1584 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'LedgerSMB')
-rwxr-xr-xLedgerSMB/Template.pm60
-rwxr-xr-xLedgerSMB/Template/CSV.pm2
-rwxr-xr-xLedgerSMB/Template/HTML.pm4
-rwxr-xr-xLedgerSMB/Template/PDF.pm2
-rwxr-xr-xLedgerSMB/Template/PS.pm2
-rwxr-xr-xLedgerSMB/Template/TXT.pm2
6 files changed, 62 insertions, 10 deletions
diff --git a/LedgerSMB/Template.pm b/LedgerSMB/Template.pm
index de0fa797..ba17f03e 100755
--- a/LedgerSMB/Template.pm
+++ b/LedgerSMB/Template.pm
@@ -11,17 +11,58 @@ This module renders templates.
=over
-=item new(user => \%myconfig, template => $string, format => 'HTML', [language => $string,] [include_path => $path], [no_auto_output => $bool], [method => $string], [no_escape => $bool]] );
+=item new(user => \%myconfig, template => $string, format => $string, [language => $string], [include_path => $path], [no_auto_output => $bool], [method => $string], [no_escape => $bool], [debug => $bool] );
This command instantiates a new template:
-template is the file name of the template to be processed.
-format is the type of format to be used. Currently only HTML is supported
-language (optional) specifies the language for template selection.
-include_path allows one to override the template directory and use this with user interface templates.
-no_auto_output disables the automatic output of rendered templates.
-no_escape disables escaping on the template variables.
-method is the output method to use, defaults to HTTP
-media is a synonym for method
+
+=over
+
+=item template
+
+The name of the template file to be processed.
+
+=item format
+
+The format to be used. Currently HTML, PS, PDF, TXT and CSV are supported.
+
+=item language (optional)
+
+The language for template selection.
+
+=item include_path (optional)
+
+Overrides the template directory. Used with user interface templates.
+
+=item no_auto_output (optional)
+
+Disables the automatic output of rendered templates.
+
+=item no_escape (optional)
+
+Disables escaping on the template variables.
+
+=item debug (optional)
+
+Enables template debugging.
+
+With the TT-based renderers, HTML, PS, PDF, TXT, and CSV, the portion of the
+template to get debugging messages is to be surrounded by
+<?lsmb DEBUG format 'foo' ?> statements. Example:
+
+ <tr><td colspan="<?lsmb columns.size ?>"></td></tr>
+ <tr class="listheading">
+ <?lsmb FOREACH column IN columns ?>
+ <?lsmb DEBUG format '$file line $line : [% $text %]' ?>
+ <th class="listtop"><?lsmb heading.$column ?></th>
+ <?lsmb DEBUG format '' ?>
+ <?lsmb END ?>
+ </tr>
+
+=item method/media (optional)
+
+The output method to use, defaults to HTTP. Media is a synonym for method
+
+=back
=item render($hashref)
@@ -64,6 +105,7 @@ sub new {
$self->{format} = 'PS' if lc $self->{format} eq 'postscript';
$self->{language} = $args{language};
$self->{no_escape} = $args{no_escape};
+ $self->{debug} = $args{debug};
if ($args{outputfile}) {
$self->{outputfile} =
"${LedgerSMB::Sysconfig::tempdir}/$args{outputfile}";
diff --git a/LedgerSMB/Template/CSV.pm b/LedgerSMB/Template/CSV.pm
index c0ff7276..9f494d69 100755
--- a/LedgerSMB/Template/CSV.pm
+++ b/LedgerSMB/Template/CSV.pm
@@ -81,6 +81,8 @@ sub process {
START_TAG => quotemeta('<?lsmb'),
END_TAG => quotemeta('?>'),
DELIMITER => ';',
+ DEBUG => ($parent->{debug})? 'dirs': undef,
+ DEBUG_FORMAT => '',
}) || throw Error::Simple Template->error();
if (not $template->process(
diff --git a/LedgerSMB/Template/HTML.pm b/LedgerSMB/Template/HTML.pm
index 6ec7b833..ae518e18 100755
--- a/LedgerSMB/Template/HTML.pm
+++ b/LedgerSMB/Template/HTML.pm
@@ -75,12 +75,14 @@ sub process {
my $parent = shift;
my $cleanvars = shift;
my $template;
-
+
$template = Template->new({
INCLUDE_PATH => $parent->{include_path},
START_TAG => quotemeta('<?lsmb'),
END_TAG => quotemeta('?>'),
DELIMITER => ';',
+ DEBUG => ($parent->{debug})? 'dirs': undef,
+ DEBUG_FORMAT => '',
}) || throw Error::Simple Template->error();
if (not $template->process(
get_template($parent->{template}),
diff --git a/LedgerSMB/Template/PDF.pm b/LedgerSMB/Template/PDF.pm
index 9c315d62..aca26f71 100755
--- a/LedgerSMB/Template/PDF.pm
+++ b/LedgerSMB/Template/PDF.pm
@@ -81,6 +81,8 @@ sub process {
START_TAG => quotemeta('<?lsmb'),
END_TAG => quotemeta('?>'),
DELIMITER => ';'
+ DEBUG => ($parent->{debug})? 'dirs': undef,
+ DEBUG_FORMAT => '',
}) || throw Error::Simple Template::Latex->error();
if (not $template->process(
diff --git a/LedgerSMB/Template/PS.pm b/LedgerSMB/Template/PS.pm
index f8c048d0..9833dba1 100755
--- a/LedgerSMB/Template/PS.pm
+++ b/LedgerSMB/Template/PS.pm
@@ -81,6 +81,8 @@ sub process {
START_TAG => quotemeta('<?lsmb'),
END_TAG => quotemeta('?>'),
DELIMITER => ';',
+ DEBUG => ($parent->{debug})? 'dirs': undef,
+ DEBUG_FORMAT => '',
}) || throw Error::Simple Template::Latex->error();
if (not $template->process(
diff --git a/LedgerSMB/Template/TXT.pm b/LedgerSMB/Template/TXT.pm
index a950335f..055a6cdd 100755
--- a/LedgerSMB/Template/TXT.pm
+++ b/LedgerSMB/Template/TXT.pm
@@ -62,6 +62,8 @@ sub process {
START_TAG => quotemeta('<?lsmb'),
END_TAG => quotemeta('?>'),
DELIMITER => ';',
+ DEBUG => ($parent->{debug})? 'dirs': undef,
+ DEBUG_FORMAT => '',
}) || throw Error::Simple Template->error();
if (not $template->process(