Template:Test-mode/doc

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 CorporisPublica: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:

To add test-mode to your template, modify the code of your template so it looks like this:

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 " " in it. If you want to disable test-mode then just change the text to " " 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" 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: " ". 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: The "test1-" part is not case sensitive.
 * Test1-Pagename
 * CorporisPublica:Test1-Pagename
 * CorporisPublica:Test1-Pagename/subpagename
 * User:Username/test1-Subpagename

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:

If you put " " 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:

Test-mode notice
Consider adding the test-mode notice at the top of the documentation of templates that use. It looks like this:

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  or inside a piped link. 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.