![]() | This proposal is part of "A Dozen Visions for Wikitext". Shortcuts: Versioning - Grunge - Markdown - HTML-only wikis - Extension tag fragments - Syntax uniformity - Colon replacement - Backticks - Syntax for Discussions - #media - #lang - #balance - Long arguments - Variable-length/structured arguments - Annotations - Visual Templates - Page Description Language - Native Script Editing - One Wiki |
{{#balance}}
{{#balance}}
Here’s a short fragment of wikitext. Is “bar” going to be in boldface, or not?
''' foo {{tpl}} bar ''' baz
This is a trick question! The answer depends on the contents of the template tpl
:
{{tpl}}
expands to a
or '''a'''
or <b>
{{tpl}}
expands to '''a
or '''''a''
or </b>
We can address this unpredictability with a mechanism called “balance”. Broadly, it ensures that any contexts opened in a fragment are closed at the end of the fragment. In addition to providing more predictable behavior for editors and ensure that the dreaded “boldface spilling out all over the rest of the article” bug doesn’t occur, it also enables some key performance updates by allowing incremental update of parsed content. And of course, it ensures good behavior of a large number of wikitext features, not just boldface. To get technical, {{#balance}}
enables a principled and strongly-typed composition semantics for wikitext.
Returning to our example:
''' foo {{tpl}} bar ''' baz
If the template tpl
opts-in to balance, we can be assured that bar
will always be bolded; nothing will “leak out” of tpl
into the outer context.
Next section: Long arguments