Template:Testcase table/doc
This is a documentation subpage for Template:Testcase table. It may contain usage information, categories and other content that is not part of the original template page. |
This template uses Lua: |
This template generates a table of side-by-side testcases comparing two or more templates. Each template is called with the same parameters.
All parameters passed to this template are passed through to the test-case templates, with the exception of parameters starting with an underscore character ("_"), which are reserved for internal use.
If no templates are specified explicitly, the module uses the base page of the current page as the first template, and its /sandbox subpage as the second template. If only one template is specified explicitly, its /sandbox subpage is used as the second template.
Usage
[edit]Basic syntax
{{Testcase table | [param1] = [value1] | [param2] = [value2] | [param3] = [value3] ... }}
Full syntax
{{Testcase table | _format = | _class = | _style = | _caption = | _rowheader = | _heading0 = | _before = | _after = | _collapsible = | _resetRefs = | _code = | _showcode = | _showheader = | _template = | _template1 = | _showtemplate1 = | _heading1 = | _template2 = | _showtemplate2 = | _heading2 = | _template3 = | _showtemplate3 = | _heading3 = ... | [param1] = [value1] | [param2] = [value2] | [param3] = [value3] ... }}
Parameters
[edit]Parameter | Description |
---|---|
_template1 _template2 (etc) |
Names of the templates to be processed. _template1 's default is the current page's {{basepage}} . If _template1 is specified, the default for _template2 is its /sandbox subpage; if not, the default for _template2 is the /sandbox subpage of the current page's basepage. Template names should be entered as you would use them in a normal template invocation, i.e. "3x", not "Template:3x". If you need to test a page in the main namespace you can use a colon prefix, i.e. ":article name".
|
_template |
Alias for _template1 . If both _template and _template1 are specified, _template will take precedence.
|
_showtemplate1 , _showtemplate2 , _showtemplate3 ... |
If this is set to "no", then no output is shown for that template. This is useful if you only want to show the main template, or if you only want to show the sandbox template. |
_heading1 _heading2 (etc) |
Custom headings for each of the templates. |
_showheader |
If this is set to "no", then no headers are shown. |
_class |
HTML classes for the table. Use |_class=wikitable to format the table as a wikitable.
|
_style |
Custom inline CSS for the table. |
_caption |
Custom caption for the table. The default is "Side by side comparison". |
_rowheader |
An extra heading for the row containing the templates. |
_heading0 |
If _rowheader is supplied, this is an optional heading above it in the template row.
|
_before , _after |
This text is displayed before or after (respectively) the output of each template. These parameters introduce no whitespace on their own. |
_collapsible |
If set to "yes", the test case is made collapsible. The test case is collapsed and given a green heading if all the template outputs are the same. If any of the template outputs differ, the test case is expanded and given a yellow heading. |
_resetRefs |
If set to "yes", any references generated by the templates tested are reset after each template is expanded. |
_showcode |
Show the template code used to make the test case. If an invocation is specified with the _code parameter, then that is used. Otherwise, an approximation is generated from the arguments. This approximation is not perfect (whitespace in named arguments is lost; duplicate arguments are ignored) but it should be fine for template code that is input all on one line without spaces between parameters.
|
_code |
Used to specify template code inside <nowiki>...</nowiki> tags. This is used with the _showcode option to display the template invocation while preserving whitespace. You must use the magic word "__TEMPLATENAME__" instead of the template name. For example: |_code=<nowiki>{{__TEMPLATENAME__|first|second|foo=bar}}</nowiki> . If you find yourself using this option a lot, you may want to consider using {{Test case nowiki}}, which allows you to generate the entire test case from template code in nowiki tags, saving you from typing in all the arguments twice. Note: due to the way nowiki tags work, the template treats the HTML entities <, > and " as if they were the literal characters <, > and " when used with this parameter. |
_format |
It is possible to use this parameter to display completely different formats, for example test cases arranged in rows. Not all of the parameters here will work with the other formats. For details, see Template:Test case's documentation. |
Examples
[edit]Example 1
[edit]using Template:Year in South Africa, with |_showcode=true
- Usage
{{Testcase table |_template=Year in South Africa |_showcode=true |1600s |nocat=true }}
- Output
{{Year in South Africa|1600s |nocat=true}}
{{Year in South Africa}} | {{Year in South Africa/sandbox}} | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
Example 2
[edit]using Template:Infobox, with |_showcode=true
and |_caption=
- Usage
{{Testcase table |_template=Infobox |_showcode=true |_caption= |title=title |above=above |header1=header1 |label2=label2 |data2=data2 |label3=label3 |data3=data3 |below=below }}
- Output
{{Infobox|above=above |below=below |data2=data2 |data3=data3 |header1=header1 |label2=label2 |label3=label3 |title=title}}
{{Infobox}} | {{Infobox/sandbox}} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
This is a sandbox, right? That means I can test stuff out in here. Example usage[edit]Typing in this: {{User:27 is the best number/sandbox
|name = {{Flag icon|Soviet Union|(dark version)}} Union of Soviet Socialist Republics 2.0 {{Flag icon|Soviet Union|(dark version)}}
|nativename = Союз Советских Социалистических Республик 2.0<br>
<small>''Soyuz Sovetskikh Sotsialisticheskikh Respublik 2.0''</small>
|founded = 2022
|predicon = Russia
|predsuffix = (1914-1917)
|onlypredecessor = Russia
|ended = 2763
|nexticon = the United States
|nextsuffix = (Pantone)
|onlysuccessor = American imperialism
|image = 2022 Russian invasion of Ukraine.svg
|caption = I WILL DESTROY EVERYTHING
|government = {{Flag icon|Soviet Union}} Absolute dictatorship
|personality = [[File:Hammer and sickle.svg|23x15px]] Communist empire
|language = {{Flag icon|Russia}} Russian
|area = {{val|22,402,200|u=km2|fmt=commas}}
|population = 290,644,721
|type = {{Flag icon|Yugoslavia|(1918–1941)}} East Slavic
|capital = {{Flag icon|Moscow}} [[Moscow]]
|largestcity = {{Flag icon|Saint Petersburg}} [[Saint Petersburg]]
|affiliation = [[File:BRICS 2024 Russian chairmanship logo.svg|23x15px]] [[BRICS]]<br>
{{Flag icon|CSTO}} [[CSTO]]<br>
{{Flag icon|Eurasian Economic Union}} [[Eurasian Union]]<br>
{{Flag icon|Union State}} [[Union State]]
|religion = You could make a reli— No, don't.
|friends = {{Flag icon|Belarus}} [[Belarus]]
|enemies = {{Flag icon|United States}} [[United States]]<br>
{{Flag icon|Ukraine}} [[Ukraine]]
|likes = [[File:Hammer and sickle.svg|23x15px]] [[Communism]]
|hates = [[File:Coronavirus. SARS-CoV-2.png|23x15px]] [[SARS-CoV-2|COVID-19]], [[File:Capitalismlogo.svg|23x15px]] [[Capitalism]]
|predecessor = {{Flag icon|Russia}} [[Russia]]
|successor = <s>Puppet of {{Flag icon|United States}} the [[United States]]</s>
|intospace = Yes
|intosea = Yes <s>but actually no</s>
|bork = Invade Ukraine Invade Ukraine
|food = <s>{{Flag icon|Ukraine}} [[Ukraine]]</s> vodka
|status = Fictional
|notes = This is a just a joke with all parameters filled so that users know what each one would look like
}}
...will result in this:
|
Technical limitations
[edit]See Template:Test case#Technical limitations for this template's known technical limitations.
See also
[edit]Templates invoking Module:Template test case:
- Template:Test case – a generalised test case template
- Template:Testcase rows – for a table of test cases arranged in rows
- Template:Inline test case – for test cases with small invocations and small output
- Template:Collapsible test case – for test cases collapsed by default if the results are the same
- Template:Test case nowiki – for test cases from template invocations enclosed in
<nowiki>...</nowiki>
tags - Template:Nowiki template demo – for use in template documentation
Other templates:
- Template:Parameter names example – produces an example of a template by using the names of that template's parameters as the values for those parameters.