Template formatting style

RESOLVED DUPLICATE of bug 107917

Status

()

Bugzilla
bugzilla.org
RESOLVED DUPLICATE of bug 107917
17 years ago
6 years ago

People

(Reporter: gerv, Assigned: CodeMachine)

Tracking

Details

Please add the following documentation about template code formatting style:

We use a 2-space indent. Embedded code sections should be on their own line, in
line with outer tags. This is somewhat analogous to code indentation style. So:

<fred>
[% IF foo %]
  <bar>
  [% FOREACH x = barney %]
    <tr>
      <td>
        [% x %]
      </td>
    <tr>
  [% END %]
[% END %]
</fred> 

- Like code, don't extend past 80 chars - break lines, in the middle of
multi-attributed tags if necessary.
- Use parameterised blocks for repeated code. 
- See current templates for ideas on how to do stuff.

CCing bbaetz FYI.

Gerv
Additional conventions:

- templates have the .tmpl filename extension (including template fragments.)
- template location on the filesystem should be reviewed before any cvs add or
checkin happens - mail reviewers@bugzilla.org.
- A couple of parameter names are reserved. 
  - "action" is reserved for choosing the action of a single script with multiple 
    possible things to do
  - "format" is reserved for choosing an output format for the data

There will be more about filenames, but that's enough to be going on with.

Gerv
Options for templates (we _seriously_ need to merge all these, and the global
functions, into a common routine/global hash which can be extended on a
case-by-case basis):

INCLUDE_PATH => "template/custom:template/default"
PRE_CHOMP => 1

(Note that RELATIVE => 1 is not required - that allows template path names to
have ../ in them, or ./ - is this a bug in TT? It appears to be explicit in the
code, so I'd guess not)

USe supplied filters where available.

I think we can probably lose the large intro comment before each one, now.

Why 2, and not 4, BTW?
> <merging templates into global declaration>

Myk is on the case - it's in one of his patches.

> Why 2, and not 4, BTW?

We've had this debate :-) 2 because the indentation level in HTML and template
code is usually far greater than that in Perl. Using 4 means you run out of room
far too quickly.

Gerv
bbaetz: note that these are recommendations/conventions, not rules.  If 4-space
indent works better in some situations, use it.  These guidelines work well in
most cases and should help promote consistency through the code, but patch
writers and reviewers can always make exceptions where it is useful to do so.
(Assignee)

Updated

17 years ago
Target Milestone: --- → Bugzilla 2.16
(Assignee)

Comment 5

17 years ago
Moving process information bug to the web site component and taking them.
Assignee: barnboy → matty
Component: Documentation → bugzilla.org
(Assignee)

Comment 6

17 years ago
Most of this is done, I have problems with the template formatting, so that part
isn't in, and I'll raise that ASAP.
(Assignee)

Updated

17 years ago
Target Milestone: Bugzilla 2.16 → Bugzilla 2.18

*** This bug has been marked as a duplicate of 107917 ***
Status: NEW → RESOLVED
Last Resolved: 15 years ago
Resolution: --- → DUPLICATE
clearing target on INVALID/WORKSFORME/WONTFIX/DUPLICATE so they'll show up as
untriaged if they get reopened.
Target Milestone: Bugzilla 2.18 → ---
QA Contact: matty_is_a_geek → default-qa
You need to log in before you can comment on or make changes to this bug.