Jump to content

User:Bb010g/sandbox/Template:Call wikitext/doc

From Wikipedia, the free encyclopedia

{{Call wikitext}} allows wikitext to be called as if it were part of a template. The contents of the <nowiki>...</nowiki> tag, or unprocessed wikitext from {{Make code}} etc., passed to |sourceCode= parameter will be called with the other arguments passed to this template.

This template is useful for documentation pages of module like Module:For nowiki and Module:ArgRest that require parent frame arguments to function or for defining parameters with complex logic that are used a few times in a short section of wikitext.

Usage

[edit]

{{Call wikitext|sourceCode=<nowiki>wikitext to call</nowiki>|parameters to call with}}

When used it invoke a module, its usage is like so:

{{Call wikitext|sourceCode=<nowiki>{{#invoke:module|function|child frame parameters}}</nowiki>|parent frame parameters}}

The |sourceCode= parameters take the wikitext to call wrapped in <nowiki>...</nowiki> tags. This parameter is not passed to the wikitext.

Examples

[edit]
  • {{Call wikitext|sourceCode=<nowiki>{{{1}}}{{#if:{{{twice|}}}|{{sp}}{{{1}}}}}</nowiki>|{{#expr:5 + 3}}}} → 8
  • {{Call wikitext|sourceCode=<nowiki>{{#invoke:ArgRest|main|&lt;nowiki>{{{1}}}! &lt;/nowiki>|1}}</nowiki>|One|Two|Three}} → One! Two! Three!
  • {{Call wikitext|sourceCode=<nowiki>{{#invoke:ArgRest|main|<nowiki>{{{1}}}! </nowiki>|1}}</nowiki>|One|Two|Three|unstripSourceCode=yes}} → {{#invoke:ArgRest|main|<nowiki>1! </nowiki>|One|Two|Three|unstripSourceCode=yes}}
  • {{Call wikitext|sourceCode=<nowiki>{{#invoke:ArgRest|main|<nowiki>{{{1}}}! → {{Call wikitext|sourceCode=<nowiki>{{#invoke:ArgRest|main|<nowiki>{{{1}}}! </nowiki>|One|Two|Three|unstripSourceCode=yes}}</nowiki>}}
  • One! Two! Three!
  • {{Call wikitext|sourceCode={{#tag:nowiki|{{((}}#invoke:ArgRest{{!}}main{{!}}{{#tag:nowiki|{{(((}}1{{)))}}! }}{{!}}1{{))}}}}|One|Two|Three}} → One! Two! Three!
  • {{Call wikitext|sourceCode={{#tag:nowiki|{{((}}#invoke:ArgRest{{!}}main{{!}}{{#tag:nowiki|{{(((}}1{{)))}}! }}{{!}}1{{))}}}}|One|Two|Three|unstripSourceCode=yes}} → One! Two! Three!


  • {{Call wikitext|sourceCode={{Make code|<<<3>>> <<<2>>> <<<1>>>}}|A|B|C}} → C B A


  • {{Call wikitext|sourceCode=Unstripped: <nowiki>Foo ''bar''</nowiki>}} → Unstripped: Foo bar
  • {{Call wikitext|sourceCode=Unstripped: <nowiki>Foo ''bar''</nowiki>|unstripSourceCode=yes}} → Unstripped: Foo bar
  • {{Call wikitext|sourceCode=Not unstripped: <nowiki>Foo ''bar''</nowiki>|unstripSourceCode=no}} → Not unstripped: Foo ''bar''
  • {{Call wikitext|sourceCode={{{1}}}|<nowiki>Foo ''bar''</nowiki>|unstripSourceCode=yes}} → Foo ''bar''
  • {{Call wikitext|sourceCode={{{1}}}|<nowiki>Foo ''bar''</nowiki>|unstripSourceCode=no}} → Foo ''bar''
  • {{Call wikitext|sourceCode=Not expanded: <nowiki>{{Make code|<<<3>>> <<<2>>> <<<1>>>}} → {{Call wikitext|sourceCode=Not expanded: <nowiki>{{{3}}} {{{2}}} {{{1}}}
  • {{Call wikitext|sourceCode=Expanded: <nowiki>{{Make code|<<<3>>> <<<2>>> <<<1>>>}} → {{Call wikitext|sourceCode=Expanded: <nowiki>{{{3}}} {{{2}}} {{{1}}}
  • {{Call wikitext|sourceCode=Expanded: {{Make code|(((3))) (((4))) '''(((1)))''' {{#tag:nowiki|'''(((2)))'''}}| {=( | }=) }}|A|B|'''C'''|<nowiki>'''D'''</nowiki>|unstripSourceCode=no}} → Expanded: C '''D''' A '''(((2)))'''
  • {{Call wikitext|sourceCode=Expanded: {{Make code|(((3))) (((4))) '''(((1)))''' {{#invoke:Lua call|call|mw.text.nowiki|'''(((2)))'''}}| {=( | }=) }}|A|B|'''C'''|<nowiki>'''D'''</nowiki>|unstripSourceCode=yes}} → Expanded: C '''D''' A '''B'''

See also

[edit]