Wikipedia:Template sandbox and test cases: Difference between revisions

Thought I'd add the location of the sandbox links and alternative sandboxes, as when I came here, I really was unable to work out where I should be editing. Hope the little extra information helps newbies figure it out!
(Undid revision 727134661 by 188.48.113.148 (talk))
(Thought I'd add the location of the sandbox links and alternative sandboxes, as when I came here, I really was unable to work out where I should be editing. Hope the little extra information helps newbies figure it out!)
{{Wikipedia how to|WP:TEMPTEST|WP:TESTCASE|WP:TESTCASES}}
 
[[Help:Template|Templates]] are a very powerful feature of [[MediaWiki]], but mistakes can be easily made, even by experienced users. Complex templates should therefore be accompanied by [[Sandbox (software development)|sandboxes]] and [[test case]]s to prevent bugs. Experimentation may also be carried out in the temporary sandboxes [[Template:X1|X1]]-[[Template:X20|X20]] or the [[Template:Template_sandbox|Template Sandbox]].
 
== Sandbox and testcases subpage naming ==
Most protected templates already have a sandbox subpage and testcases subpage. The names of these pages are default. TemplatesAt withthe documentationbottom subpagesof existingeach willtemplate's automaticallypage includeare links to create\edit the template's sandbox and testcases pages (and make "create" links if they do not exist).
 
For example, here are the subpages for '''{{tl|FlagIOCmedalist}}''':
|}
 
== For whatWhat kind of templates should you use sandbox for ==
 
It is highly recommended to apply the test case pattern to templates using [[mw:Help:Extension:ParserFunctions|ParserFunctions]] that can generate very different looking output, such as the ones that take many parameters, or the ones that have many branches of the <code>#switch</code> operator.
 
For navigational boxes, ofwith which the outputs are almostmostly identical results on each transcluding page, the benefit may not outweigh the time and effort to create a sandbox page, but if in doubt, sandbox it. Any template that is marked as a [[Wikipedia:High-risk templates|High-risk Template]] should always be tested before an edit is made. With other pages, you should still check which pages use the template (via the "What Links Here" link in the Tools section of the linkbar at the left side of the screen).
 
Any template that is [[Wikipedia:High-risk templates|transcluded in thousands of pages]] should of course be tested before an edit is made.
 
== How to create /sandbox and /testcases subpages ==
# Suppose your template is named <code>Template:X</code>. Create a subpage with the name <code>Template:X/sandbox</code>. If the main template is using the {{tl|documentation}} template, you can do this from a link at the bottom of the blue documentation box on the template main page. Or you can type it into the search box, or directly into the URL bar of your browser. Note that "/sandbox" is all lowercase.
# Copy the entire contents of the main template, including <code><nowiki><noinclude></nowiki></code> tags and the {{tl|documentation}} template if present, paste it into the edit window of the /sandbox subpage, and save the page. Your edit summary should be something like "create sandbox version of [[Template:X]]".
#* Note: if you use the "mirror" link at the bottom of the blue documentation box, tags like <code><nowiki><noinclude></nowiki></code>, and their contents, will be missing. It's best just to copy and paste manually.