Jump to content

Template:Expand wikitext/doc

From Wikipedia, the free encyclopedia

Interprets the input as wikitext using the frame:preprocess function. Any arguments passed to {{Expand wikitext}} are available in the preprocessed code, letting this be used as a rudimentary way of using variables.

If the entire input is in a nowiki tag, or if the optional parameter |unstrip=yes is specified, first extracts the contents of nowiki tags before preprocessing.

Examples

[edit]
  • {{Expand wikitext|If there is no wiki markup, the template doesn't do anything.}} → If there is no wiki markup, the template doesn't do anything.
  • {{Expand wikitext|Wiki markup wrapped in nowiki is not expanded without the unstrip parameter: <nowiki>Foo ''bar''</nowiki>}} → Wiki markup wrapped in nowiki is not expanded without the unstrip parameter: Foo ''bar''
  • {{Expand wikitext|Wiki markup wrapped in nowiki is expanded with the unstrip parameter: <nowiki>Foo ''bar''</nowiki>|unstrip=yes}} → Wiki markup wrapped in nowiki is expanded with the unstrip parameter: Foo bar
  • {{Expand wikitext|<nowiki>If the whole text is wrapped in nowiki, it is expanded without the unstrip parameter: Foo ''bar''</nowiki>}} → If the whole text is wrapped in nowiki, it is expanded without the unstrip parameter: Foo bar
  • {{Expand wikitext|<nowiki>{{As of|2015|02}}</nowiki>}} → As of February 2015
  • {{Expand wikitext|Wikitext produced by a template invocation is expanded: {{Make code|<<As of!2015!02>>}}}} → Wikitext produced by a template invocation is expanded: As of February 2015
  • {{Expand wikitext|<nowiki>The value of foo is {{{foo}}}</nowiki>|foo=123}} → The value of foo is 123
  • {{Expand wikitext|<nowiki>The value of foo minus 56 is {{#expr:({{{foo}}})-56}}</nowiki>|foo=123}} → The value of foo minus 56 is 67

The template may produce unexpected results in case the wikitext contains a dash - right before or after a template invocation, i.e. -{ or }-, because these are interpreted as language converter markup. See T168759 and mw:Writing systems/Syntax for details. As a workaround, replace - by &#45;.

  • {{Expand wikitext|<nowiki>This works. - {{2x|x}} -</nowiki>}} → This works. - xx -
  • {{Expand wikitext|<nowiki>This doesn't work. -{{2x|x}}</nowiki>}} → This doesn't work. -{{2x|x}}
  • {{Expand wikitext|<nowiki>This doesn't work. {{2x|x}}-</nowiki>}} → This doesn't work. {{2x|x}}-
  • {{Expand wikitext|<nowiki>This works. &#45;{{2x|x}}&#45;</nowiki>}} → This works. -xx-

The template escapes HTML tags in input that is wrapped in <nowiki>, which may produce unexpected results:

  • {{Expand wikitext|'''bold''', <b>bold</b>, ''italic'', <i>italic</i>}}bold, bold, italic, italic
  • {{Expand wikitext|'''bold''', <b>bold</b>, <nowiki>''italic'', <i>italic</i></nowiki>|unstrip=yes}}bold, bold, italic, <i>italic</i>
  • {{Expand wikitext|<nowiki>'''bold''', <b>bold</b>, ''italic'', <i>italic</i></nowiki>}}bold, <b>bold</b>, italic, <i>italic</i>

See also

[edit]
  • {{Make code}}
  • {{Call wikitext}} - Always unstrips nowiki tags and uses |sourceCode= to avoid parameter overlap