Closed Bug 280770 Opened 20 years ago Closed 20 years ago

Bugzilla::Constants should be available to templates

Categories

(Bugzilla :: Bugzilla-General, defect)

2.19
defect
Not set
normal

Tracking

()

RESOLVED FIXED
Bugzilla 2.20

People

(Reporter: myk, Assigned: myk)

Details

Attachments

(2 files, 1 obsolete file)

Bugzilla::Constants should be available to templates so that they can use them
for conditional processing without us having to duplicate the set of constants
or individually include them in the variables hash.
It's a small patch that does something simple, but it has to do some
complicated symbol table lookups, hence the density.  Still, a very cool way to
give us constants in TT, and I would think it would be right up your alley
bbaetz.
Assignee: general → myk
Status: NEW → ASSIGNED
Attachment #173164 - Flags: review?(bbaetz)
Comment on attachment 173164 [details] [diff] [review]
patch v1: exposes constants to templates

Mark, can you review this dense but short enhancement to our templating code?
Attachment #173164 - Flags: review?(wurblzap)
Comment on attachment 173164 [details] [diff] [review]
patch v1: exposes constants to templates

This is really useful.

Unfortunately, array constants are mishandled -- for them, the hash contains
the number of their entries. I would have expected a reference to the array,
right?
Attachment #173164 - Flags: review?(wurblzap) → review-
>Unfortunately, array constants are mishandled -- for them, the hash contains
>the number of their entries. I would have expected a reference to the array,
>right?

Right.	This patch fixes that.
Attachment #173164 - Attachment is obsolete: true
Attachment #173321 - Flags: review?(wurblzap)
Attachment #173164 - Flags: review?(bbaetz)
Comment on attachment 173321 [details] [diff] [review]
patch v2: works for array constants

This is good.
Do we want a note in Constants.pm saying that there shouldn't be any functions
added? (The file name doesn't really invite anybody to add a function, but...)
Attachment #173321 - Flags: review?(wurblzap) → review+
Thanks Marc!

Checking in Bugzilla/Template.pm;
/cvsroot/mozilla/webtools/bugzilla/Bugzilla/Template.pm,v  <--	Template.pm
new revision: 1.20; previous revision: 1.19
done

>Do we want a note in Constants.pm saying that there shouldn't be any functions

>added? (The file name doesn't really invite anybody to add a function, but...)


I was thinking about it, and I started to add a note in a followup patch, but
then I realized a better approach would be to traverse the @EXPORT and
@EXPORT_OK arrays instead of the whole symbol table.  Then we'd only get the
symbols the Constants module wanted to make available, which should all be
constants, and there's no danger of someone adding an internal function to
Constants.pm that we end up reflecting into the template object.

So here's a followup patch with that fix.
Attachment #173376 - Flags: review?(wurblzap)
Attachment #173376 - Flags: review?(wurblzap) → review+
Flags: approval?
Thanks Marc!

Bugzilla/Template.pm
Checking in Bugzilla/Template.pm;
/cvsroot/mozilla/webtools/bugzilla/Bugzilla/Template.pm,v  <--  Template.pm
new revision: 1.21; previous revision: 1.20
done
Status: ASSIGNED → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
Flags: approval? → approval+
Target Milestone: --- → Bugzilla 2.20
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: