summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Bugzilla/Template/Plugin/Hook.pm63
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>