Template code
- Empty loops should generate no html. Empty lists, tables or other tags should be avoided. Like so:
<tmpl_if item_loop>
The above is usually the best way, but __FIRST__ and __LAST__ can be used when appropriate.
<ul>
<tmpl_loop item_loop>
<li>...</li>
</tmpl_loop>
</ul>
</tmpl_if> - Fix/add a bug report for template variables that are incorrect or not working.
- File RFEs for inconsistent use of variables. For example: the attachment loop in the article template differs from the one in the collaborations system.
- Pay attention to i18n: is everything internationalized? If not, add an RFE.
- HTML and template code should be properly nested. When you use tmpl_if or tmpl_unless, you should check if HTML is still valid if that condition doesn't apply. Mistakes like this one, for example, are easy to miss (when your code is complex):
<tmpl_if user.canEdit>
<p>
<a href="">edit</a>
</tmpl_if>
<tmpl_if user.isModerator>
<a href="">delete</a>
</tmpl_if>
</p>