May 182007
 

I was starting to poke at the documentation plan for Firefox 3 today, and got to some content that had already been written. I was looking it over, making a few fixes (mostly adding our new, spiffy “New in Firefox 3” templates as appropriate, when I realized that the new attributes added to the textbox XUL element in some cases overlap in name with attributes that already exist.

Previously, we would have to create multiple pages of documentation for that attribute, but now that we have the ParserFunctions MediaWiki extension installed, it’s possible to do conditional pages that look at the title of the page being built and adjust the text to match.

The attribute pages (such as this one for the min attribute) are included by the pages that describe the elements that support them. MediaWiki’s PAGENAME variable tells us the name of the page that’s being described. The cool thing is that it tells us the name of the master element page that’s being rendered — not the name of the included attribute’s page.

That means we can use PAGENAME as a condition for deciding what text to display in the article. For example, the min attribute’s body text looks like this in an editor:
The minimum value that the {{#switch: {{PAGENAME}} |
XUL:textbox = number box |
XUL:scale = scale | scale or number box}}
may be set to. The default value is 0.

When this is rendered by visiting the attribute’s page directly, the text reads “The minimum value that the scale or number box may be set to. The default value is 0.”

If it’s included from the textbox page, the result is “The minimum value that the number box may be set to. The default value is 0.”

From the scale page, the result is “The minimum value that the scale may be set to. The default value is 0.”

This is a very powerful capability we have now, and I think we’re going to find a lot of valuable applications for it going forward.

 Posted by at 6:47 PM