Any chance this can slide into the developers release(s) leading up to 2.12?
-myk
Myk Melez wrote:
While evaluating the "component" special variable for something I'm working on I noticed that if a template processes another template, the first template's component variable is set to the second template's component variable afterwards....
The attached patch to that function fixes the problem by storing the value of that variable before processing any templates and then reseting it to that value after processing is done.
diff -ur Template-Toolkit-2.10b/lib/Template/Context.pm Template-Toolkit-2.10b-component-fix/lib/Template/Context.pm --- Template-Toolkit-2.10b/lib/Template/Context.pm 2003-12-02 14:42:12.000000000 +0100 +++ Template-Toolkit-2.10b-component-fix/lib/Template/Context.pm 2004-01-02 20:27:25.000000000 +0100 @@ -293,7 +293,7 @@ my ($self, $template, $params, $localize) = @_; my ($trim, $blocks) = @$self{ qw( TRIM BLOCKS ) }; my (@compiled, $name, $compiled); - my ($stash, $tblocks, $error, $tmpout); + my ($stash, $component, $tblocks, $error, $tmpout); my $output = ''; $template = [ $template ] unless ref $template eq 'ARRAY'; @@ -318,6 +318,7 @@ } eval { + eval { $component = $stash->get('component') }; foreach $name (@$template) { $compiled = shift @compiled; my $element = ref $compiled eq 'CODE' @@ -352,6 +353,7 @@ } $output .= $tmpout; } + $stash->set('component', $component); }; $error = $@;
