ទំព័រគំរូ:Test-mode
This template is new, it needs some more testing before we can fully trust it, so don't use it on any high-risk templates just yet. We might do some changes to it over the next few weeks. --David Göthberg (talk) 21:35, 15 February 2010 (UTC) |
This is the {{test-mode}} template.
It can be used to live-test new versions of templates. It is especially useful for testing meta-templates and sub-templates that might be several steps away from the templates placed on the pages, so we can't call the test versions directly.
This template provides a "test-mode" that makes the meta-templates display their test version instead of the normal version, so we can surf around and see how the test version behaves on real pages. Only the users that want to see the test-mode see it, all other users still see the normal version of the templates.
Preparing your template
[កែប្រែ]Note! Before using this test system, use your template's /sandbox and /testcases subpages to test your code. See Wikipedia:Template test cases. If your code has basic errors like missing end braces "}}
" or pipes "|
" in the wrong places it will bleed through and be visible also to normal users.
Say you have a template with this code:
<!-- The current code of your template. --><noinclude> {{documentation}} </noinclude>
To add test-mode to your template, modify the code of your template so it looks like this:
{{test-mode | test1 version = <!--New code to test--> | normal version = <!--The currently deployed code that most users see--> }}<noinclude> {{documentation}} </noinclude>
When pages that use your template are read or edited most users will see the part of the template fed as "normal version". Only users in test-mode will see the "test1 version" of the template. See the sections below for how to enter test-mode.
Test-mode user script
[កែប្រែ]There are several ways to see pages in test-mode. The most convenient way is to use the user script User:Bawolff/test-mode.js. (More documentation coming soon. Meanwhile learn more about the script at the talk page.)
Personal test-mode
[កែប្រែ]The second method to see pages in test-mode is the "personal test-mode":
Create a subpage under your user page called "/test-mode.css" and put the text "test1
" in it. If you want to disable test-mode then just change the text to "off
" or just blank it. The reason we use a .css page for this is that such pages can only be edited by the user himself and by admins.
Then you can go to any page that is using your template and simply click "edit this page". Your template will now display in test-mode when in edit preview, since you are in personal test-mode. Other users will see the template's normal output even in edit preview, since they are not in personal test-mode.
If you don't see edit preview immediately when clicking "edit this page", then you can enable that in "my preferences - Editing - Show preview on first edit".
Personal test-mode only works in edit preview, for technical reasons we can't make it work when just viewing pages.
Note that personal test-mode probably will stop working some day, since it will only work as long as our devs don't "fix" bugzilla:19006. But in most cases this is the more convenient and easy to use test-mode.
Page test-mode
[កែប្រែ]The third method to see a page in test-mode is based on the pagename:
Say you want view the article named "Example" in test-mode. Then open the page "Test1-Example" and add this code in it: "{{:Example}}
". Then simply preview "Test1-Example" to see how your template looks in test-mode on that page. (This means you are transcluding the entire "Example" article onto the page "Test1-Example". The colon ":
" is needed when transcluding articles since otherwise MediaWiki tries to transclude "Template:Example" instead.)
Don't save "Test1-" pages in article space. If you want to save the test page so you can show it to other users, then for instance create a subpage in your user space named like this: "User:Your username/test1-Example". Note that such test pages will have most of the categories that the article itself has, so don't keep such test pages for too long.
Page test-mode triggers both on basebages and subpages that begin with "test1-". All these work:
- Test1-Pagename
- Wikipedia:Test1-Pagename
- Wikipedia:Test1-Pagename/subpagename
- User:Username/test1-Subpagename
The "test1-" part is not case sensitive.
Several test-modes
[កែប្រែ]This template has three test-modes: test1, test2 and test3. This means you can test several versions of a template at the same time. Like this:
{{test-mode | test1 version = <!--New code to test--> | test2 version = <!--New code to test--> | test3 version = <!--New code to test--> | normal version = <!--The currently deployed code that most users see--> }}<noinclude> {{documentation}} </noinclude>
If you put "test2
" in your personal /test-mode.css or use page names like "Test2-Pagename" you will see the test2 version.
Test-mode demo
[កែប្រែ]This section of this documentation uses {{test-mode}} to show different text depending on if you are viewing this page as a normal user, or in one of the test-modes. This is so you can check that you managed to turn on a test-mode. So try a test-mode and see what this section says:
- You are viewing this section as a normal user.
Test-mode notice
[កែប្រែ]Consider adding the {{test-mode notice}} at the top of the documentation of templates that use {{test-mode}}. It looks like this:
If you are going to edit this template, please note that it is currently using {{test-mode}} for some advanced testing. |
See its documentation for reasons to add that notice.
Technical details
[កែប្រែ]If your template is using tables, then you need to know this:
Templates have a problem to handle parameter data that contains pipes "|
", unless the pipe is inside another template {{name|param1}}
or inside a piped link [[Help:Template|help]]
. Thus templates can not handle wikitables as input unless you escape them by using the {{!}} template. This makes it hard to use wikitables as parameters to templates. Instead the usual solution is to use "HTML wikimarkup" for the table code, which is more robust.
For more technical details, see the talk page.
See also
[កែប្រែ]- Wikipedia:Template test cases – About the normal test approach that should be done before using the test-mode.