Skip Menu |

This queue is for tickets about the Template-Toolkit CPAN distribution.

Report information
The Basics
Id: 57206
Status: resolved
Priority: 0/
Queue: Template-Toolkit

People
Owner: Nobody in particular
Requestors: dekimsey [...] at.ufl.edu
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 2.22
Fixed in: (no value)



Subject: When creating a new document Provider uses global DOCUMENT instead of self's
The provider object already defines its own DOCUMENT class to be used for creating a Template document. Other places in the code properly reference the $self->{DOCUMENT}, this line seemed to have been overlooked when the code was refactored. Wrote a quick-n-dirty test and added it to provider.t
Subject: self-document.patch
diff -ur Template-Toolkit-2.22/lib/Template/Provider.pm Template-Toolkit-2.22p/lib/Template/Provider.pm --- Template-Toolkit-2.22/lib/Template/Provider.pm 2008-11-13 03:30:46.000000000 -0500 +++ Template-Toolkit-2.22p/lib/Template/Provider.pm 2010-05-04 14:23:43.000000000 -0400 @@ -891,7 +891,7 @@ unless ($error) { return $data ## RETURN ## - if $data->{ data } = $DOCUMENT->new($parsedoc); + if $data->{ data } = $self->{DOCUMENT}->new($parsedoc); $error = $Template::Document::ERROR; } } diff -ur Template-Toolkit-2.22/t/provider.t Template-Toolkit-2.22p/t/provider.t --- Template-Toolkit-2.22/t/provider.t 2008-11-13 03:30:45.000000000 -0500 +++ Template-Toolkit-2.22p/t/provider.t 2010-05-04 14:58:18.000000000 -0400 @@ -251,8 +251,23 @@ ttd2 => $ttd2, ttdbad => $ttd3 ]; -test_expect(\*DATA, $uselist, $vars); +#------------------------------------------------------------------------ +# What about if a DOCUMENT class is specified. +#------------------------------------------------------------------------ +require "$lib/document.pm" || die $!; +is $provabs->{DOCUMENT}, 'Template::Document', "Default document class is specified ok"; +my $provdoc = Template::Provider->new({ + ABSOLUTE => 1, + DOCUMENT => 'Test::Template::Document', + LOAD_TEMPLATES => [ $provabs ], +}) || die $Template::Provider::ERROR; +is $provdoc->{DOCUMENT}, 'Test::Template::Document', "Custom document class is specified ok"; +my ($doc_abs) = $provabs->fetch($absfile); +my ($doc_oth) = $provdoc->fetch($absfile); +is ref $doc_abs, 'Template::Document'; +is ref $doc_oth, 'Test::Template::Document'; +test_expect(\*DATA, $uselist, $vars); __DATA__ -- test --
Ticket migrated to github as https://github.com/abw/Template2/issues/173