FANDOM


 
Line 7: Line 7:
 
** for yourself. Be assured that you will find it hard to understand what you have written when you revisit a template six months later.
 
** for yourself. Be assured that you will find it hard to understand what you have written when you revisit a template six months later.
 
** for categorization. Categories should always be included on the documentation page, not in the tempate itself.
 
** for categorization. Categories should always be included on the documentation page, not in the tempate itself.
** for testing purposes. The <code><nowiki>{{documentation}</nowiki></code> automatically detects if there are test pages for this template and displays the links. The links will be red if there are no such pages.
+
** for testing purposes. <code><nowiki>{{documentation}}</nowiki></code> automatically detects if there are test pages for this template and displays the links. The links will be red if there are no such pages.
 
* Testing you templates: When other editors start to use your template, they will at best be surprised when you suddenly change something or just test new code that may not work. In the worst case, your changes disrupt the display of hundreds of pages. That's what the /sandbox and /testcases subpages are for. These are the two test pages automatically linked by the documentation template as described above.
 
* Testing you templates: When other editors start to use your template, they will at best be surprised when you suddenly change something or just test new code that may not work. In the worst case, your changes disrupt the display of hundreds of pages. That's what the /sandbox and /testcases subpages are for. These are the two test pages automatically linked by the documentation template as described above.
 
** /sandbox: Copy the code of the original template here, then you can change everything you want without interrupting the display of the original template. Remember that the test version has to be called with <code><nowiki>{{Example/sandbox}}</nowiki></code> rather than <code><nowiki>{{Example}}</nowiki></code>.
 
** /sandbox: Copy the code of the original template here, then you can change everything you want without interrupting the display of the original template. Remember that the test version has to be called with <code><nowiki>{{Example/sandbox}}</nowiki></code> rather than <code><nowiki>{{Example}}</nowiki></code>.

Latest revision as of 19:35, January 14, 2020

As for your template plan, here are a few general helpful hints:

  • When you write a template, add <noinclude>{{documentation}}</noinclude> directly after the last character, without spaces. This will create a documentation for your template that will be shown when someone displays it.
  • At first, there is only a [create] link. Click on it, and you will get a predefined page with a draft structure.
  • Documentation is important
    • for other users trying to understand what you wrote.
    • for yourself. Be assured that you will find it hard to understand what you have written when you revisit a template six months later.
    • for categorization. Categories should always be included on the documentation page, not in the tempate itself.
    • for testing purposes. {{documentation}} automatically detects if there are test pages for this template and displays the links. The links will be red if there are no such pages.
  • Testing you templates: When other editors start to use your template, they will at best be surprised when you suddenly change something or just test new code that may not work. In the worst case, your changes disrupt the display of hundreds of pages. That's what the /sandbox and /testcases subpages are for. These are the two test pages automatically linked by the documentation template as described above.
    • /sandbox: Copy the code of the original template here, then you can change everything you want without interrupting the display of the original template. Remember that the test version has to be called with {{Example/sandbox}} rather than {{Example}}.
    • /testcases: This is a place for you to see your changes in action. You can try out {{Example/sandbox}} with different parameters to see if everything works right. As templates and template subpages don't always display changes after saving, you may want to add {{Purge}} at the top of the page to easily clear the cache and reload the page.
    • {{Extrapolate pro upgrade price a8}} is an example where I added the bike price progression first in /sandbox, tested it in /testcases and then copied the whole new code from /sandbox to the original template when everything worked as expected.

Happy coding!

P. S.:
En anglais, « redondant » s'écrit « redundant ». ;-)

Community content is available under CC-BY-SA unless otherwise noted.