Mar 172010

We have a few new and changed templates on MDC that I’d like to share, that will help make various things easier to mark up, and will clarify some edge cases that needed clarification.

Changed templates

Several templates have been improved to do a better job of directing to the correct language, even when used in unusual workspaces in the wiki (for example, domxref and cssxref both work correctly when used in the Project subtree of the wiki.

Also, the templates that automatically add text listing applications based on a given Gecko version (gecko_minversion_header, for example), have been revised so that instead of each of them embedding all the code to figure out and insert the application versions, they each use a sub-template, geckoRelease, to do this work. This will obviously make updating these templates much less painful in the future.

Changes to the “obsolete_inline” template

The obsolete_inline template, used to tag items in a list or table as obsolete, now accepts an optional parameter that indicates the Gecko version in which the API became obsolete. If provided, the text in the displayed tag changes from simply “Obsolete” to “Obsolete in Gecko X”.

Changes to the “domxref” template

The domxref template is used to create a link to a page in the Gecko DOM Reference. It’s been revised so that if you include parentheses at the end of the name of the destination, the link is created to the corresponding page but with parentheses displayed at the end of the name, so that it’s clear that the link is to a method. For example, {{domxref(“document.getElementsByName()”)}} creates a link to “” that is displayed as “document.getElementsByName()”.

New templates

There are also several cool new templates.

Creating Gecko version call-out boxes

In the past, it’s been tricky to include text that applies to a specific version of Gecko (or later) in an article that otherwise also applies to older version of Gecko. We now have a special template and CSS class that work together to let you create boxes — from single line notes to full article sections — that apply to specific Gecko versions.

First, here’s a screen shot of what it looks like in Firefox trunk nightlies:

Screen shot from Firefox nightly

Note the stylish use of CSS gradients here. The CSS smartly falls back to using solid colors if you’re not using a browser that supports Mozilla’s proposed syntax for gradients.

To use this, you start by using the gecko_callout_heading template, like this:


This creates the title. Then you write all your text that belongs in the callout box. You can use code samples, other templates, styles, and so forth as you need to. Then select the entire section that belongs in the callout box, including the title template, and click the div button in the editor’s toolbar:

This brings up the “Create Div Container” dialog box:

Choose the “Version note box” style and click OK. That will apply the appropriate styles so that when the page is viewed, the callout box is all beautiful.

You may note that “Version note box” is listed in the Style popup in the editor’s toolbar. Don’t let this fool you! Choosing it will not work correctly; it will wrap each paragraph or block you have selected in its own box, which is not what you want.

The new “renamed_inline” template

The new renamed_inline template can be used to tag an API in a list or table as having been renamed. This makes it easy to update documentation to reflect changed names. The template accepts two parameters: the previous name of the API and the version of Gecko in which the API’s name changed. For example, {{renamed_inline(“oldapiname”, “1.9.1”)}} would add a little box that says “Renamed from oldapiname in Gecko 1.9.1″.

The new “HTMLElement” template

The new HTMLElement template inserts a link to an element’s documentation in our HTML element reference.

 Posted by at 2:45 PM

  One Response to “MDC template improvements”

  1. […] Bit Stampede » Blog Archive » MDC template improvements […]

This site uses Akismet to reduce spam. Learn how your comment data is processed.