Problem with TT variables
Jon Wilmoth
JWilmoth at starbucks.com
Wed Jun 25 18:04:02 UTC 2003
I'm working on a patch for
http://bugzilla.mozilla.org/show_bug.cgi?id=13540 and am not having any
success implementing the variable names the way Gerv has suggested
(required?). This bug basically tries to turn a few Bugzilla terms into
variables that can be customized. The approach I took was to create a
hash of terms in a new file global/variables.none.tmpl and reference
them in the various templates that use those terms. Sounds simple
enough, but getting the variables to be declared and referenced in one
way is proving very difficult for a TT newbie. There are basically
three code usage scenarios in which the template variables need to work:
1) Simple in-template usage (example from
template/en/default/bug/create/create.html.tmpl):
(Leave all boxes unchecked to make this a public [%
global.terms.bug %].)
2) Process usage (example from
template/en/default/bug/create/create.html.tmpl):
[% PROCESS global/header.html.tmpl
title = "Enter $global.terms.Bug"
h2 = "This page lets you enter a new $global.terms.bug
into $global.terms.Bugzilla."
%]
3) In-template hash definition (example from
template/en/default/global/field-descs.none.tmpl):
[% field_descs = { "[Bug creation]" => "[$global.terms.Bug
creation]",
The only code I've been able to get working under all three cases is:
1) Including the variable file - [% INCLUDE global/variables.none.tmpl
%]
2) Defining the hash in variables.none.tmpl using the global namespace
keyword like so:
[% global.terms = {
bug = "bug",
Bug = "Bug",
abug = "a bug",
Abug = "A bug",
bugs = "bugs",
Bugs = "Bugs",
zeroSearchResults = "Zarro Boogs found",
bit = "bit",
bits = "bits",
Bugzilla = "Bugzilla"
}
%]
3) Referencing the termanology variables using [% global.terms.bug %]
(scenario 1) or $ global.terms.bug (scenario 2 & 3).
Changing the way the variables are brought into a template to - [%
PROCESS global/variables.none.tmpl %] instead of INCLUDE allows the
variables has to be declared and referenced without the global prefix in
usage scenario #1, but they are not resolved under usage scenarios #2 &
#3.
I realize this is somewhat against the normal usage of includes as
normally you pass variables *TO* an include/process page instead of
attempting to use variables defined *BY* an include, but if anyone knows
TT well enough to give me some direction, I'd appreciate it.
More information about the developers
mailing list