![]() | This is a documentation subpage for Template:Inline test case. It contains usage information, categories and other content that is not part of the original template page. |
![]() | This template uses Lua: |
This template generates a test case comparing two or more templates for inline templates. The template invocation and the result must all fit on one line, otherwise it may return strange results.
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
editBasic syntax
{{inline test case | [param1] = [value1] | [param2] = [value2] | [param3] = [value3] ... }}
Full syntax
{{inline test case | _format = | _collapsible = | _resetRefs = | _code = | _showcode = | _template = | _template1 = | _showtemplate1 = | _template2 = | _showtemplate2 = | _template3 = | _showtemplate3 = ... | [param1] = [value1] | [param2] = [value2] | [param3] = [value3] ... }}
Parameters
editParameter | Description |
---|---|
_template1 , _template2 , _template3 ... |
The names of the templates to be processed. The default of _template1 is the base page of the current page. If _template1 is specified, the default for _template2 is its /sandbox subpage; if not, the default for _template2 is the /sandbox subpage of the base page of the current page. 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 |
An 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. |
_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 |
Set to "no" to disable the display of the template code for each template. 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, and 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 use this option, take care to ensure that the template invocation is all contained on one line; if not, the template may produce unexpected results. 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 columns. Not all of the parameters here will work with the other formats. For details, see the documentation of Template:Test case. |
Example
editusing Template:3x
- Usage
{{inline test case|_template=3x|ipsum lorem }}
- Output
{{3x|ipsum lorem }}
→ ipsum lorem ipsum lorem ipsum lorem{{3x/sandbox|ipsum lorem }}
→ ipsum lorem ipsum lorem ipsum lorem
Technical limitations
editAs this template starts with a bullet, a newline will always be inserted at the start of the template output due to bug 14974. See Template:Test case#Technical limitations for other known technical limitations.
See also
editTemplates 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:Testcase table – for a table of test cases arranged in columns
- 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