![]() | 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 |
Let's look at an example from a Wikimania 2015 talk, "Future of structured documents: VisualEditor, Citations and Wikidata, oh my!", which shows a reference in the article Nahuatl. This is a template to create a citation region using Wikidata: this region of the text is supposed to be supported by reference 32412 stored with WikiCite. Here's the syntax:
{{cite id=“32412”|
First person plural pronouns in Isthmus-Mecayapan Nahuat:
:''nejamēn'' ({{IPA|[nehameːn]}}) "We, but not you" (= me & them)
:''tejamēn'' ({{IPA|[tehameːn]}}) "We along with you" (= me & you & them)
}}
But this doesn’t work: instead of displaying its first argument it displays nothing! why?
It’s these equal signs here:
It turns out that there are a number of “special” characters you can’t naively include in a template argument, and equals sign is one of them. Everything here to the left of the first equal sign is treated as the name of the first argument, and thus there is in fact no argument “1” defined here.[1]
There are a number of such “gotchas” when trying to pass arguments to templates or parser functions. I gave a talk at Wikimania 2015 (updated in 2024) going through a lot of them. Long argument syntax is an effort to provide a “quote” syntax to make it easier to pass arguments without having to “properly escape” them, if you can figure out what “properly escape” means.
Here’s what it looks like, just triple angle brackets on either side of the argument:
Now | With long arguments |
---|---|
{{Largethumb| Foo.jpg| caption}} |
{{Largethumb|Foo.jpg|<<< caption >>>}} |
Here’s an example that is difficult or confusing to write currently:
Now | With long arguments |
---|---|
{{tablestart}}
|
{{Table|<<<
|
The workaround to date has been to have two separate “start” and “end” templates (tablestart
and tableend
here), in order to avoid the need to figure out how to properly escape the body. But those two templates aren’t balanced (remember {{#balance}}
?) and make it slower to reparse, hard to edit this table using VisualEditor, etc. But with long arguments we can easily create a balanced “table” template and put the table cells in the argument.
Like extension tag syntax, long arguments allow anything to be passed except the magic >>>
close sequence. But if you need to pass that particular character, for example to nest quoted arguments, you can do that as well using the same mechanism we introduced for extension tag fragments.
Extension tag fragments | Long arguments fragments |
---|---|
<ref>
|
{{#tag:ref|<<<
|
At the risk of inconsistency with extension tag fragments, we might consider flipping this and making nesting of <<<
>>>
work by default, which would reserve fragments for the case where we explicitly want to pass an unbalanced <<<
or >>>
:
The goal is not to invent special escape syntax but instead to interpret characters literally and just allow changing the delimiters if necessary.[2]
Going back to our first example, it makes it easy to pass arbitrary content to our citation template, without having to watch our for equals signs and other bad characters:
Next section: Variable-length/structured arguments