Hi all,
I have some questions about the way the templating system would work in an
ideal world (not necessarily how it works today). I'm attempting to write a
template processor that mimics the ideal behavior of MW's templating engine.
I'm running into difficulties when considering edge cases. Take for example
four nested brackets: {{{{a}}}}
I would have thought that this was equivalent to calling the template whose
name is output after calling {{a}}. So if Template:A contains just "b", I'd
expect {{{{a}}}} to be equivalent to {{b}} - however this is not the case,
and the raw text "{{{{a}}}}" is returned.
In the #mediawiki IRC channel, someone helpfully suggested {{{{void}}{{a}}}}
- which does what I expected {{{{a}}}} to do. However, this doesn't really
help me from a requirements standpoint - as it doesn't answer whether
{{{{a}}}}'s behavior is an intentional, conscientious design choice, or
merely a missing feature.
Another thing I've noticed is that template parameters (three brackets) bind
more tightly than template calls (two brackets). So five brackets like this
{{{{{a}}}}} is similar to {{ {{{a}}} }}. However, six brackets like this
{{{{{{a}}}}}} resolves to {{{ {{{a}}} }}} and the inner parameter is
replaced leaving {{{a's value}}}. The outer triple is left as plain text.
Generally speaking, as long as there are breaks, it appears the parser can
figure out the intent, which is why {{{{void}}{{a}}}} succeeds where
{{{{a}}}} fails.
Any advice on how to handle these edge cases (nested brackets beyond 2 or 3)
would be much appreciated.
-- Jim R. Wilson (jimbojw)