Redigerer
Mal:Test case nowiki/dok
Hopp til navigering
Hopp til søk
Advarsel:
Du er ikke innlogget. IP-adressen din vil bli vist offentlig om du redigerer. Hvis du
logger inn
eller
oppretter en konto
vil redigeringene dine tilskrives brukernavnet ditt, og du vil få flere andre fordeler.
Antispamsjekk.
Ikke
fyll inn dette feltet!
{{Documentation subpage}} {{lua|Module:Template test case}} <!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see [[Wikipedia:Wikidata]]) --> This template generates a test case for two or more templates. Each template is called with the same parameters, and the test case can be displayed in various different formats. The template output and the template invocations are generated from template code passed inside {{tag|nowiki}} tags passed to the {{para|code}} or {{para|1}} parameters. In this template code, you must use the magic word <code>__TEMPLATENAME__</code> instead of the normal template name. Template names are specified parameters like {{para|template1}} and {{para|template2}}, etc. 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''' <pre> {{test case nowiki|<nowiki>{{__TEMPLATENAME__ | [param1] = [value1] | [param2] = [value2] | [param3] = [value3] ... }}</nowiki>}} </pre> '''Common syntax''' The following options will work with all different test case formats. <pre> {{test case nowiki | format = | collapsible = | resetRefs = | showcode = | showheader = | template = | template1 = | showtemplate1 = | heading1 = | template2 = | showtemplate2 = | heading2 = | template3 = | showtemplate3 = | heading3 = ... | code = <nowiki>{{__TEMPLATENAME__ | [param1] = [value1] | [param2] = [value2] | [param3] = [value3] ... }}</nowiki> }} </pre> Some test case formats accept additional parameters as well. See their sections for documentation. == Parameters == {| class="wikitable" |+ Common parameters |- ! Parameter !! Description |- | <code>code</code> or <code>1</code> || The template code, inside {{tag|nowiki}} tags. You must use the magic word "__TEMPLATENAME__" instead of the template name. For example: <code><nowiki>| code = <nowiki>{{__TEMPLATENAME__|first|second|foo=bar}}</nowiki></nowiki></code>. <p>Note: due to the way nowiki tags work, the template treats the [[HTML entities]] &lt;, &gt; and &quot; as if they were the literal characters <, > and " when used with this parameter.</p> |- | <code>format</code> || The format to display the test cases in. This can be "columns", "rows", "inline" or "default". |- | <code>template1</code>, <code>template2</code>, <code>template3</code>... || 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''". |- | <code>template</code> || An alias for template1. If both template and template1 are specified, template will take precedence. |- | <code>showtemplate1</code>, <code>showtemplate2</code>, <code>showtemplate3</code>... || 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. |- | <code>heading1</code>, <code>heading2</code>, <code>heading3</code>... || Custom headings for each of the templates. |- | <code>showheader</code> || If this is set to "no", then no headers are shown. |- | <code>collapsible</code> || 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. |- | <code>resetRefs</code> || If set to "yes", any references generated by the templates tested are reset after each template is expanded. |- | <code>showcode</code> || Set this to "no" to disable showing the template code used to make the test case. |} The default test case format doesn't have any extra parameters. The inline format is for test cases that can be displayed entirely on one line. If used with templates that display on multiple lines it may produce unexpected results. It doesn't have any extra parameters. The columns format arranges the test cases side by side in a table. This is useful for comparing long and thin templates such as infoboxes. It has the following extra parameters: {| class="wikitable" |- ! Parameter !! Description |- | <code>class</code> || HTML classes for the table. Use {{para|class|wikitable}} to format the table as a wikitable. |- | <code>style</code> || Custom inline CSS for the table. |- | <code>caption</code> || Custom caption for the table. The default is "Side by side comparison". |- | <code>rowheader</code> || An extra heading for the row containing the templates. |- | <code>heading0</code> || If rowheader is supplied, this is an optional heading above it in the template row. |- | <code>after</code> || This text is displayed after the output of each template. |} The rows format arranges the test cases in rows in a table. It has the following extra parameters: {| class="wikitable" |- ! Parameter !! Description |- | <code>class</code> || HTML classes for the table. Use {{para|class|wikitable}} to format the table as a wikitable. |- | <code>style</code> || Custom inline CSS for the table. |- | <code>caption</code> || Custom caption for the table. |} You can use {{para|collapsible|yes}} with any format to turn it into a collapsible test case. If all the template outputs are the same the test case is collapsed and given a green heading. If any of the template outputs differ, the test case is expanded and given a yellow heading. You can set a custom title for collapsible test cases with the {{para|title}} parameter. == Examples == === Default === ;Usage <pre style="white-space:pre-wrap; overflow:auto; background-color:#eee;"> {{test case nowiki|template1=ombox|code=<nowiki>{{__TEMPLATENAME__|text=Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.}}</nowiki>}} </pre> ;Output {{test case nowiki|template1=ombox|code=<nowiki>{{__TEMPLATENAME__|text=Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.}}</nowiki>}} === Default, collapsible === ;Usage <pre style="white-space:pre-wrap; overflow:auto; background-color:#eee;"> {{test case nowiki|template1=ombox|collapsible=yes|<nowiki>{{__TEMPLATENAME__|text=Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.}}</nowiki>}} </pre> ;Output {{test case nowiki|template1=ombox|collapsible=yes|<nowiki>{{__TEMPLATENAME__|text=Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.}}</nowiki>}} === Default, collapsible, different output === ;Usage <pre style="white-space:pre-wrap; overflow:auto; background-color:#eee;"> {{test case nowiki|template1=ombox|template2=tmbox|collapsible=yes|title=Example of differing output|<nowiki>{{__TEMPLATENAME__|text=Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.}}</nowiki>}} </pre> ;Output {{test case nowiki|template1=ombox|template2=tmbox|collapsible=yes|title=Example of differing output|<nowiki>{{__TEMPLATENAME__|text=Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.}}</nowiki>}} === Inline === using [[Template:3x]] ;Usage <pre style="white-space:pre-wrap; overflow:auto; background-color:#eee;"> {{test case nowiki|template1=3x|collapsible=yes|format=inline|code=<nowiki>{{__TEMPLATENAME__|Lorem ipsum}}</nowiki>}} </pre> ;Output {{test case nowiki|template1=3x|format=inline|code=<nowiki>{{__TEMPLATENAME__|Lorem ipsum}}</nowiki>}} Note: As this format starts with a bullet, a newline will always be inserted at the start of the template output due to [[phab:T14974|bug 14974]]. === Inline, collapsible === ;Usage <pre style="white-space:pre-wrap; overflow:auto; background-color:#eee;"> {{test case nowiki|template1=3x|format=inline|code=<nowiki>{{__TEMPLATENAME__|Lorem ipsum}}</nowiki>}} </pre> ;Output {{test case nowiki|template1=3x|collapsible=yes|format=inline|code=<nowiki>{{__TEMPLATENAME__|Lorem ipsum}}</nowiki>}} === Columns === ;Usage <pre style="white-space:pre-wrap; overflow:auto; background-color:#eee;"> {{test case nowiki|template1=ombox|format=columns|code=<nowiki>{{__TEMPLATENAME__|text=Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.}}</nowiki>}} </pre> ;Output {{test case nowiki|template1=ombox|format=columns|code=<nowiki>{{__TEMPLATENAME__|text=Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.}}</nowiki>}} === Columns, collapsible === ;Usage <pre style="white-space:pre-wrap; overflow:auto; background-color:#eee;"> {{test case nowiki|template1=ombox|collapsible=yes|format=columns|title=Using the columns format|<nowiki>{{__TEMPLATENAME__|text=Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.}}</nowiki>}} </pre> ;Output {{test case nowiki|template1=ombox|collapsible=yes|format=columns|title=Using the columns format|<nowiki>{{__TEMPLATENAME__|text=Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.}}</nowiki>}} === Rows === ;Usage <pre style="white-space:pre-wrap; overflow:auto; background-color:#eee;"> {{test case nowiki|template1=ombox|format=rows|code=<nowiki>{{__TEMPLATENAME__|text=Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.}}</nowiki>}} </pre> ;Output {{test case nowiki|template1=ombox|format=rows|code=<nowiki>{{__TEMPLATENAME__|text=Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.}}</nowiki>}} === Rows, collapsible === ;Usage <pre style="white-space:pre-wrap; overflow:auto; background-color:#eee;"> {{test case nowiki|template1=ombox|collapsible=yes|format=rows|title=Using the rows format|<nowiki>{{__TEMPLATENAME__|text=Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.}}</nowiki>}} </pre> ;Output {{test case nowiki|template1=ombox|collapsible=yes|format=rows|title=Using the rows format|<nowiki>{{__TEMPLATENAME__|text=Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.}}</nowiki>}} == Technical limitations == The template has the following known technical limitations: * An error will be generated if processing the entire page takes more than 10 seconds. This is an intentional limit in the [[mw:Extension:Scribunto|Scribunto]] extension that runs [[Module:Template test case]], on which this template is based. If a test cases page takes more than 10 seconds to load, you may need to split it up into different pages. * The template converts the [[HTML entities]] &lt;, &gt; and &quot; inside template invocations to the literal characters <, > and ". This is due to the way nowiki tags work. * For collapsible test cases, all text inside extension tags (e.g. {{tag|ref|o}}, {{tag|references|o}}, {{tag|gallery|o}} and {{tag|nowiki|o}}) is treated as equal. These tags are converted to [[Help:Strip markers|strip markers]] before they are passed to the template, and all strip markers include a random string as they have to be unique. Even if strip markers were unstripped before being compared, the same wikitext would not be guaranteed to result in exactly the same unstripped code. So this module ignores the content of strip markers for the purposes of testing equality. This has the unwanted side effect that, e.g. <code><nowiki>Some text<ref>foo</ref></nowiki></code> is treated as equal to <code><nowiki>Some text<gallery>bar</gallery></nowiki></code>, but should be adequate for most uses. == See also == 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:Testcase table]] – for a table of test cases arranged in columns * [[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:Nowiki template demo]] – for use in template documentation <includeonly>{{Sandbox other|| <!-- Categories below this line, please; interwikis at Wikidata --> [[Category:Template test cases| ]] [[Category:Template namespace templates]] [[Category:Wikitext processing templates]] }}</includeonly>
Redigeringsforklaring:
Merk at alle bidrag til Wikisida.no anses som frigitt under Creative Commons Navngivelse-DelPåSammeVilkår (se
Wikisida.no:Opphavsrett
for detaljer). Om du ikke vil at ditt materiale skal kunne redigeres og distribueres fritt må du ikke lagre det her.
Du lover oss også at du har skrevet teksten selv, eller kopiert den fra en kilde i offentlig eie eller en annen fri ressurs.
Ikke lagre opphavsrettsbeskyttet materiale uten tillatelse!
Avbryt
Redigeringshjelp
(åpnes i et nytt vindu)
Forhåndsvis en side som bruker denne malen
Denne siden er medlem av 1 skjult kategori:
Kategori:Sider hvor ekspansjonsdybden er overskredet
Navigasjonsmeny
Personlige verktøy
Ikke logget inn
Brukerdiskusjon
Bidrag
Opprett konto
Logg inn
Navnerom
Mal
Diskusjon
norsk bokmål
Visninger
Les
Rediger kilde
Vis historikk
Mer
Navigasjon
Forside
Siste endringer
Tilfeldig side
Hjelp til MediaWiki
Verktøy
Lenker hit
Relaterte endringer
Spesialsider
Sideinformasjon