summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Template.pm
diff options
context:
space:
mode:
authormyk%mozilla.org <>2005-02-08 01:43:09 +0100
committermyk%mozilla.org <>2005-02-08 01:43:09 +0100
commit2e7ff851909cc108b2f885df08f4e92ec539a4ba (patch)
treeee4fa968efc222c2aab85f51ce58c26245a6fc50 /Bugzilla/Template.pm
parentf6d4395710e88c108882a1d94e89f813d8e3f452 (diff)
downloadbugzilla-2e7ff851909cc108b2f885df08f4e92ec539a4ba.tar.gz
bugzilla-2e7ff851909cc108b2f885df08f4e92ec539a4ba.tar.xz
Followup fix for bug 280770: improves reflection of constants into the templates' 'constants' namespace; r=wurblzap, a=myk
Diffstat (limited to 'Bugzilla/Template.pm')
-rw-r--r--Bugzilla/Template.pm13
1 files changed, 9 insertions, 4 deletions
diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm
index a764848be..d4fcbe27c 100644
--- a/Bugzilla/Template.pm
+++ b/Bugzilla/Template.pm
@@ -23,6 +23,7 @@
# Bradley Baetz <bbaetz@student.usyd.edu.au>
# Christopher Aillon <christopher@aillon.com>
# Tobias Burnus <burnus@net-b.de>
+# Myk Melez <myk@mozilla.org>
package Bugzilla::Template;
@@ -38,12 +39,16 @@ use Date::Format ();
use base qw(Template);
# Convert the constants in the Bugzilla::Constants module into a hash we can
-# pass to the template object. To do so, we have to traverse the symbol table
-# for the module, pulling out the functions (which is how Perl constants are
-# implemented) and ignoring the rest (i.e. things like the @EXPORT array).
+# pass to the template object for reflection into its "constants" namespace
+# (which is like its "variables" namespace, but for constants). To do so, we
+# traverse the arrays of exported and exportable symbols, pulling out functions
+# (which is how Perl implements constants) and ignoring the rest (which, if
+# Constants.pm exports only constants, as it should, will be nothing else).
use Bugzilla::Constants ();
my %constants;
-foreach my $constant (keys %Bugzilla::Constants::) {
+foreach my $constant (@Bugzilla::Constants::EXPORT,
+ @Bugzilla::Constants::EXPORT_OK)
+{
if (defined &{$Bugzilla::Constants::{$constant}}) {
# Constants can be lists, and we can't know whether we're getting
# a scalar or a list in advance, since they come to us as the return