Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
bugzilla
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
bugzilla
Commits
d7cf1c91
Commit
d7cf1c91
authored
7 years ago
by
Dylan William Hardison
Committed by
Jeff Fearn
7 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add a new hook: template_after_create (#60)
parent
c31565fe
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
0 deletions
+29
-0
Hook.pm
Bugzilla/Hook.pm
+15
-0
Template.pm
Bugzilla/Template.pm
+1
-0
Extension.pm
extensions/Example/Extension.pm
+13
-0
No files found.
Bugzilla/Hook.pm
View file @
d7cf1c91
...
...
@@ -1479,6 +1479,21 @@ look at the code for C<create> in L<Bugzilla::Template>.)
=back
=head2 template_after_create
This hook allows you to manipulate the Template object before it is used.
You can use this to define new vmethods or filters in extensions.
Params:
=over
=item C<template>
This is the L<Bugzilla::Template> object.
=back
=head2 template_before_process
This hook is called any time Bugzilla processes a template file, including
...
...
This diff is collapsed.
Click to expand it.
Bugzilla/Template.pm
View file @
d7cf1c91
...
...
@@ -1186,6 +1186,7 @@ sub create {
Bugzilla::Hook::
process
(
'template_before_create'
,
{
config
=>
$config
});
my
$template
=
$class
->
new
(
$config
)
||
die
(
"Template creation failed: "
.
$class
->
error
());
Bugzilla::Hook::
process
(
'template_after_create'
,
{
template
=>
$template
});
# Pass on our current language to any template hooks or inner templates
# called by this Template object.
...
...
This diff is collapsed.
Click to expand it.
extensions/Example/Extension.pm
View file @
d7cf1c91
...
...
@@ -920,6 +920,19 @@ sub template_before_create {
$config
->
{
VARIABLES
}
->
{
example_global_variable
}
=
sub
{
return
'value'
};
}
sub
template_after_create
{
my
(
$self
,
$args
)
=
@_
;
my
$context
=
$args
->
{
template
}
->
context
;
# define a pluck method on template toolkit lists.
$context
->
define_vmethod
(
list
=>
pluck
=>
sub
{
my
(
$list
,
$field
)
=
@_
;
return
[
map
{
$_
->
$field
}
@$list
];
}
);
}
sub
template_before_process
{
my
(
$self
,
$args
)
=
@_
;
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment