Commit 5aba1b12 authored by mkanat%bugzilla.org's avatar mkanat%bugzilla.org

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
parent e0db56e7
......@@ -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>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment