Difference between revisions of "Template:Collapsible test case/doc"

From blackwiki
Jump to navigation Jump to search
imported>Zyxw
(→‎See also: formatting)
imported>Vanisaac
m (→‎See also: clean up per WP:CAT#T and WP:AWBREQ add template:Sandbox other)
 
(4 intermediate revisions by 2 users not shown)
Line 28: Line 28:
 
== Examples ==
 
== Examples ==
  
<br />
+
=== Compare template and sandbox (default format) ===
; Compare template and sandbox (default format)
+
 
<pre>
+
;Usage
 +
<pre style="white-space:pre-wrap; overflow:auto; background-color:#eee;">
 
{{collapsible test case
 
{{collapsible test case
 
| _template1 = ombox
 
| _template1 = ombox
Line 36: Line 37:
 
}}
 
}}
 
</pre>
 
</pre>
 +
 +
;Output
 
{{collapsible test case
 
{{collapsible test case
 
| _template1 = ombox
 
| _template1 = ombox
Line 41: Line 44:
 
}}
 
}}
  
<br />
+
=== Compare two different templates (default format) ===
; Compare two different templates (default format)
+
 
<pre>
+
;Usage
 +
<pre style="white-space:pre-wrap; overflow:auto; background-color:#eee;">
 
{{collapsible test case
 
{{collapsible test case
 
| _template1 = ombox
 
| _template1 = ombox
Line 50: Line 54:
 
}}
 
}}
 
</pre>
 
</pre>
 +
 +
;Output
 
{{collapsible test case
 
{{collapsible test case
 
| _template1 = ombox
 
| _template1 = ombox
Line 56: Line 62:
 
}}
 
}}
  
<br />
+
=== Compare template and sandbox (rows format) ===
; Compare template and sandbox (rows format)
+
 
<pre>
+
;Usage
 +
<pre style="white-space:pre-wrap; overflow:auto; background-color:#eee;">
 
{{collapsible test case
 
{{collapsible test case
 
| _format = rows
 
| _format = rows
Line 65: Line 72:
 
}}
 
}}
 
</pre>
 
</pre>
 +
 +
;Output
 
{{collapsible test case
 
{{collapsible test case
 
| _format = rows
 
| _format = rows
Line 71: Line 80:
 
}}
 
}}
  
<br />
+
=== Compare template and sandbox (columns format) ===
; Compare template and sandbox (columns format)
+
 
<pre>
+
;Usage
 +
<pre style="white-space:pre-wrap; overflow:auto; background-color:#eee;">
 
{{collapsible test case
 
{{collapsible test case
 
| _format = columns
 
| _format = columns
Line 80: Line 90:
 
}}
 
}}
 
</pre>
 
</pre>
 +
 +
;Output
 
{{collapsible test case
 
{{collapsible test case
 
| _format = columns
 
| _format = columns
Line 86: Line 98:
 
}}
 
}}
  
<br />
+
=== Compare template and sandbox (inline format, show code) ===
; Compare template and sandbox (inline format, show code)
+
 
<pre>
+
;Usage
 +
<pre style="white-space:pre-wrap; overflow:auto; background-color:#eee;">
 
{{collapsible test case
 
{{collapsible test case
 
| _format = inline
 
| _format = inline
Line 96: Line 109:
 
}}
 
}}
 
</pre>
 
</pre>
 +
 +
;Output
 
{{collapsible test case
 
{{collapsible test case
 
| _format = inline
 
| _format = inline
Line 110: Line 125:
 
* [[Template:Inline test case]] – for test cases with small invocations and small output
 
* [[Template:Inline test case]] – for test cases with small invocations and small output
 
* [[Template:Test case nowiki]] – for test cases from template invocations enclosed in {{tag|nowiki}} tags
 
* [[Template:Test case nowiki]] – for test cases from template invocations enclosed in {{tag|nowiki}} tags
 +
* [[Template:Nowiki template demo]] – for use in template documentation
  
<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox | |
+
<includeonly>{{Sandbox other||
 
<!-- Categories below this line, please; interwikis at Wikidata -->
 
<!-- Categories below this line, please; interwikis at Wikidata -->
 
[[Category:Template test cases| ]]
 
[[Category:Template test cases| ]]
 
[[Category:Template namespace templates]]
 
[[Category:Template namespace templates]]
 
}}</includeonly>
 
}}</includeonly>

Latest revision as of 15:36, 24 April 2020

This template creates a test case of two or more templates contained in a collapsible box. If the outputs of all the templates is the same, the box is collapsed, but if any of them differ from each other the box is left uncollapsed. There are a variety of different formats and options that can be used.

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

Basic syntax

{{collapsible test case
| [param1] = [value1]
| [param2] = [value2]
| [param3] = [value3]
...
}}

Full syntax

For the full syntax, see Template:Test case. This template is equivalent to that one with the |_collapsible= parameter set to "yes" by default.

Examples

Compare template and sandbox (default format)

Usage
{{collapsible test case
| _template1 = ombox
| text = Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut tristique sagittis cursus.
}}
Output
{{ombox}}

{{ombox}}

{{ombox/sandbox}}

Error: expandTemplate: template "ombox/sandbox" does not exist

Compare two different templates (default format)

Usage
{{collapsible test case
| _template1 = ombox
| _template2 = tmbox
| text = Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut tristique sagittis cursus.
}}
Output
{{ombox}}

{{ombox}}

{{tmbox}}

Compare template and sandbox (rows format)

Usage
{{collapsible test case
| _format = rows
| _template1 = ombox
| text = Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut tristique sagittis cursus.
}}
Output
{{ombox}}
{{ombox}}
{{ombox/sandbox}}
Error: expandTemplate: template "ombox/sandbox" does not exist

Compare template and sandbox (columns format)

Usage
{{collapsible test case
| _format = columns
| _template1 = ombox
| text = Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut tristique sagittis cursus.
}}
Output
{{ombox}}
Side by side comparison
{{ombox}}{{ombox/sandbox}}
Error: expandTemplate: template "ombox/sandbox" does not exist

Compare template and sandbox (inline format, show code)

Usage
{{collapsible test case
| _format = inline
| _showcode = yes
| _template1 = ombox
| text = Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut tristique sagittis cursus.
}}
Output
{{ombox}}
  • {{ombox|text=Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut tristique sagittis cursus.}}
  • {{ombox/sandbox|text=Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut tristique sagittis cursus.}}Error: expandTemplate: template "ombox/sandbox" does not exist

See also

Templates invoking Module:Template test case: