diff options
author | mkanat%bugzilla.org <> | 2008-05-29 05:43:33 +0200 |
---|---|---|
committer | mkanat%bugzilla.org <> | 2008-05-29 05:43:33 +0200 |
commit | 5aba1b12a34c1fde3a99b3db781dbae3f0d1259f (patch) | |
tree | 57933dbd028da654c94d1cec23f6d64ca5380535 /Bugzilla/Template | |
parent | e0db56e755e94e07677faa3729a4affe38a3ce18 (diff) | |
download | bugzilla-5aba1b12a34c1fde3a99b3db781dbae3f0d1259f.tar.gz bugzilla-5aba1b12a34c1fde3a99b3db781dbae3f0d1259f.tar.xz |
Bug 318205: The path to the hook is incorrect when called from inside a block
Patch By Elliotte Martin <elliotte_martin@yahoo.com> r=mkanat, a=mkanat
Diffstat (limited to 'Bugzilla/Template')
-rw-r--r-- | Bugzilla/Template/Plugin/Hook.pm | 63 |
1 files changed, 55 insertions, 8 deletions
diff --git a/Bugzilla/Template/Plugin/Hook.pm b/Bugzilla/Template/Plugin/Hook.pm index 4e3bf5cef..05a1fdfd1 100644 --- a/Bugzilla/Template/Plugin/Hook.pm +++ b/Bugzilla/Template/Plugin/Hook.pm @@ -19,6 +19,7 @@ # # Contributor(s): Myk Melez <myk@mozilla.org> # Zach Lipton <zach@zachlipton.com> +# Elliotte Martin <everythingsolved.com> # package Bugzilla::Template::Plugin::Hook; @@ -45,12 +46,11 @@ sub new { } sub process { - my ($self, $hook_name) = @_; + my ($self, $hook_name, $template) = @_; + $template ||= $self->{_CONTEXT}->stash->{component}->{name}; + + my @hooks; - my $paths = $self->{_CONTEXT}->{LOAD_TEMPLATES}->[0]->paths; - my $template = $self->{_CONTEXT}->stash->{component}->{name}; - my @hooks = (); - # sanity check: if (!$template =~ /[\w\.\/\-_\\]+/) { ThrowCodeError('template_invalid', { name => $template}); @@ -79,6 +79,8 @@ sub process { } } } + + my $paths = $self->{_CONTEXT}->{LOAD_TEMPLATES}->[0]->paths; # we keep this too since you can still put hook templates in # template/en/custom/hook @@ -116,9 +118,54 @@ Bugzilla::Template::Plugin::Hook Template Toolkit plugin to process hooks added into templates by extensions. +=head1 METHODS + +=over + +=item B<process> + +=over + +=item B<Description> + +Processes hooks added into templates by extensions. + +=item B<Params> + +=over + +=item C<hook_name> + +The unique name of the template hook. + +=item C<template> (optional) + +The path of the calling template. +This is used as a work around to a bug which causes the path to the hook +to be incorrect when the hook is called from inside a block. + +Example: If the hook C<lastrow> is added to the template +F<show-multiple.html.tmpl> and it is desired to force the correct template +path, the template hook would be: + + [% Hook.process("lastrow", "bug/show-multiple.html.tmpl") %] + +=back + +=item B<Returns> + +Output from processing template extension. + +=back + +=back + =head1 SEE ALSO L<Template::Plugin> -L<http:E<sol>E<sol>www.bugzilla.orgE<sol>docsE<sol>tipE<sol>htmlE<sol>customization.html> -L<http:E<sol>E<sol>bugzilla.mozilla.orgE<sol>show_bug.cgi?id=229658> -L<http:E<sol>E<sol>bugzilla.mozilla.orgE<sol>show_bug.cgi?id=298341> + +L<http://www.bugzilla.org/docs/tip/html/customization.html> + +L<http://bugzilla.mozilla.org/show_bug.cgi?id=229658> + +L<http://bugzilla.mozilla.org/show_bug.cgi?id=298341> |