User:Trevor Parscal (WMF)/Ideas

Templates
My views on templates and their use are derived as much from a use-case analysis as they are from a technical point of view. The short summary of my ideas here is that templates are almost always the wrong tool for the jobs users are utilizing them for, and that serious reform needs to take place in order for MediaWiki to achieve the level of usability needed for the Wikimedia Foundation to reach it's goals.

Templates are not required to represent a discreet object
Because templates are expanded before actual wiki-text parsing takes place, they can be and often are used to generate portions of a whole wiki-text unit. This is most commonly seen in the creation of tables on Wikipedia projects, where the head and foot of a table are generated by two separate templates, while rows are generated by a combination of a number of templates. The result is a series of template calls which are associated with one another in the context of their use in a page, without any semantic association present.

To solve this, templates need to be expanded, rendered into HTML and validated before being merged into the original page. This differs from the current behavior of rendering not taking place until the entire page has been expanded. By rendering the wiki-text earlier on in the process, a reliable validation step can be added to ensure that the template is returning a single discreet HTML object such as a div or a span.

This would allow templates be integrated into a WYSIWYG editing system, and in cases where desirable be able to have their own edit links on a rendered page. In a large scope, this would actually raise the possibility of not pre-processing at all, since the entire page can be rendered with the templates being expanded or not without compromising the validity of the document. This in turn would provide the possibility of developing a wiki-text based document object model, which could treat templates as discreet nodes which can be optionally expanded.

Templates lack important semantic and meta information
The free-form nature of templates is not conducive to building editing tools around them which provide any consistency between the editing interface and the final rendered product. Some movement has taken place in defining an XML structure which can define the parameters a template takes, but the scope of this format is to define in as user-interface-agnostic way possible which parameters a template will accept and in which order as well as i18n information for labels and descriptions. It is expected that this scope may expand as needed, or that this information may be supplemented with other information if appropriate.

If this kind of information were available for all templates, rich and customizable user interfaces could be generated, and rendered pages could include additional semantic information within the markup which could be utilized by internal and external tools.