Hello, wise TT2ers.

I am having a problem getting the ERROR config option to work.  I
have been able to get it to work in the past, but for some reason,
I'm not getting it now.

Here are the files I'm using to demonstrate my problem:

test.pl:
-------------------------------------------------------------
#!/usr/bin/perl

use strict;
use warnings;
no warnings qw(uninitialized);

use Template;

my $tt = new Template(
        {
                INCLUDE_PATH => '.',
                #DEBUG => 'all',
                ERROR => 'error.html'
        }
);

my $data = { foo => 1 };

#$tt->process('test.html', $data) || die $tt->error;
$tt->process('test.html', $data);
-------------------------------------------------------------

test.html:
-------------------------------------------------------------
[%- # the following line has an intentional syntax error -%]
[%- IF foo = '2' -%]
foo is 2.
[%- ELSE -%]
foo is not 2.
[%- END %]
-------------------------------------------------------------

error.html:
-------------------------------------------------------------
Here is your error:

[% error %]
-------------------------------------------------------------

Running test.pl, I would expect the output to be:

-------------------------------------------------------------
Here is your error:

file error - parse error - test.html line 1: unexpected token (=)
  [% IF foo = '2' %] at test.pl line 19.
-------------------------------------------------------------

but instead I get no output.  If I switch the the version of the
->process() call statement with the '|| die $tt->error', I see the
error, but it isn't being processed through the error.html template.

If I uncomment the DEBUG config option, then I get:

-------------------------------------------------------------
[Template::Provider] creating cache of unlimited slots for [ . ]
[Template::Service] process(test.html, HASH(0x8114078))
[Template::Context] template(test.html)
[Template::Context] looking for block [test.html]
[Template::Context] asking providers for [test.html] []
[Template::Provider] _fetch_path(test.html)
[Template::Provider] searching path: ./test.html
[Template::Provider] _load(./test.html, test.html)
[Template::Provider] _compile(HASH(0x82ea4c0), <no compfile>)
file error - parse error - test.html line 1: unexpected token (=)
  [% IF foo = '2' %] at test.pl line 19.
-------------------------------------------------------------

My understanding is that if an ERROR option is supplied, then the
error is handed to the template specified and it is processed, with
the error template's output being used instead of the errorneous
template's output.  Is this right?  Any ideas what I might be doing
wrong to not see the error nestled in my error template?

My config:
        Perl 5.8.0
        Template 2.12a

Thanks in advance,

Dave

/L\_/E\_/A\_/R\_/N\_/T\_/E\_/A\_/C\_/H\_/L\_/E\_/A\_/R\_/N\
Dave Cash                              Power to the People!
Frolicking in Fields of Garlic               Right On-Line!
[EMAIL PROTECTED]                                  Dig it all.


_______________________________________________
templates mailing list
[EMAIL PROTECTED]
http://lists.template-toolkit.org/mailman/listinfo/templates

Reply via email to