Home
Random
Recent changes
Special pages
Community portal
Preferences
About Sundering
Disclaimers
Sundering
Search
User menu
Talk
Contributions
Create account
Log in
Patches
|
Items
|
Quests
|
Creatures
|
Dungeons
|
NPCs
Attributes
|
Skills
|
Titles
|
XP Augmentation
|
Luminance Augmentation
|
Tailoring
Character Creation
β’
New Player Guide
β’
User Interface
β’
Glossary
Editing
Help:Template
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
''See also: http://en.wikipedia.org/wiki/Help:Template'' == Parameters == A parameter, or argument, is information that the template needs to complete its job. If a parameter is required, you must include it, if it is optional you can omit it if it doesn't apply. For example if someone gives you a to do list, the purpose of the list is clear, you are supposed to do the items on the list. But for any given list, the items will differ. A template that requires parameters is the same idea. Parameters are separated with single pipes ( | ). If you need to include a pipe as part of a parameter use {{tl|!}}. Here's an example of formatting a to do list with three items using the fictional ToDoList template: <pre> {{ToDoList|Buy milk.|Return videos.|Wash car.}} </pre> How the list is formatted will depend on exactly how the actual template is setup, but here is one possibility: <div style="background-color:#E0E0E0; border:2px solid #C0C0C0;width:50%;padding:30px;margin-bottom:20px;margin-left:10%;margin-right:40%;"> <font color=#000000><big>'''To Do List'''</big> ---- # Buy milk. # Return videos. # Wash car. </font></div> === Named Variables === Unlike the ToDo list above where all the parameters are things to do, most templates that use parameters give each one an explicit name. This is needed when the parameters are formatted differently or put in particular locations. An example would be a business card template. The phone number, address, name, etc all go in particular locations and so the template needs to know which parameter is the name, which is the address, etc. For example: <pre> {{Business Card | Name = Martine Strathelar | Address = 100 Planar Drive, Dereth | Business = Temporal Translocations | Phone Number = (555)555-1212 }} </pre> which using the hypothetical Business Card template might be displayed as: <blockquote class="toccolours" style="float:none; padding: 10px 15px 10px 15px; display:table;"><br><big><center>'''''Martine Strathelar'''''</center></big><br><center>'''Temporal Translocations'''</center><br>100 Planar Drive, Dereth - (555)555-1212</blockquote> === Whitespace === Whitespace (including newlines, tabs and spaces) is stripped from the beginning and end of all parameters. If this is not desirable, adding any non-whitespace characters (including the HTML ''encoding'' for a whitespace character, or invisible Unicode characters such as the zero-width space or direction marks) will prevent further stripping: :<pre>{{#ifeq: foo | foo | equal | not equal }}</pre> :→ '''{{#ifeq: foo | foo | equal | not equal }}''' :<pre>{{#ifeq: &#32;foo &#32;|&#32; foo&#32; | equal | not equal }}</pre> :→ '''{{#ifeq: &#32; foo &#32; | &#32; foo &#32; | equal | not equal }}''' Judicious use of whitespace can make templates more readable, quicker to fill out, and easier to debug when unexpected behavior occurs. Compare the two uses below that would have identical results. <pre style="width:auto; overflow:auto"> {{Template | Parameter One = One | Parameter Two = Two | Parameter Three = Three | Parameter Four = Four }} {{Template|Parameter One=One|Parameter Two=Two|Parameter Three=Three|Parameter Four=Four}} </pre> ==== Strip/Trim ==== Some complicated templates can experience problems with how white space is used when invoking the template (where you would get different results using <nowiki>{{template | variable }} vs. {{template|variable}}</nowiki> even though technically they should be the same. Use the {{tl|Strip}} function around the variable in the template for consistent results. == Advanced Template Syntax == To use templates you won't need to know any of the following, however in order to edit an existing template or to create a new template you may find this information useful. Additional info can be found at [http://meta.wikimedia.org/wiki/Help:Template Help:Template] and [http://meta.wikimedia.org/wiki/Help:Advanced_templates Help:Advanced templates] (Wikipedia, so the information may not always apply exactly to this installation of Wikimedia software). You cannot preview changes to a template, so to avoid having broken templates for other users, test changes or new templates in the [[Template:Sandbox]]. (Don't forget to change your template's name to <nowiki>{{Sandbox}}</nowiki> to see the effects in the Sandbox.) Once it is working how you expect it to, transfer the code to the actual template page and revert the Sandbox. === Syntax === * '''<nowiki><includeonly></includeonly></nowiki>''' - Optional tags you can place around the workhorse code that defines what the template does. It will cause the code to not display on the template page, improving the appearance of the page since most variables will be undefined. Also it will not compete with an example in situations where only one of an item can be displayed, such as a table of contents. * '''<nowiki><noinclude></noinclude></nowiki>''' - Anything between these tags will be processed and displayed only when the page is being viewed directly; it will not be included or substituted in normal usage when the template is being referenced. * '''<nowiki>{{{1}}}</nowiki>''' - The first unnamed variable (parameter) from the template invocation. That is, on another page where <nowiki>{{Related|Weapons|Armor|Loot}}</nowiki> is used, Weapons would be the first unnamed variable. Increment the number for successive variables, for example <nowiki>{{{3}}}</nowiki> would reference the third unnamed variable (Loot). Where this term (<nowiki>{{{1}}}</nowiki>) is used in your template, the variable's value will be inserted. So if <nowiki>[[{{{1}}}]]</nowiki> is in your template, it will be show up as [[Loot]] on the page where you used the template. * '''<nowiki>{{{1|}}}</nowiki>''' - You can declare a default value for any variable by inserting a pipe and a default value. If the variable is undefined the default value will be given instead. For example, if the template uses <nowiki>{{{1|''No Link''}}}</nowiki> then if no value was passed, it will be assigned "No Link." * '''<nowiki>{{{Variable}}}</nowiki>''' - A named variable has an explicit name assigned with the equals sign when using the template. For example, on the page using the template you could have <nowiki>{{Business Card|Name=John Doe}}</nowiki>. This would mean that for the template "Business Card" the named variable "Name" has a value of "John Doe" and when using this on the actual template page you would use <nowiki>{{{Name}}}</nowiki> to reference this variable's value (John Doe). * '''<nowiki>{{{Variable|}}}</nowiki>''' - As described above for <nowiki>{{{1|}}}</nowiki> you can also set a default value for named variables. This can be useful for templates where you will usually use a standard value but want to retain the option of specifying a value. When using the default, just leave out the variable. For example, <nowiki>{{{align|center}}}</nowiki>. This would still let you set align=right or align=left when using the template, but if you don't use align at all, it will be center. Keep in mind if align is left blank (align = ) then the default will not be used because the value is an empty string. In other words there are three possibilities, in the example below align has a value of "top," margin has an empty value, and style is absent and would use the default value if one is given for the style variable: <pre> {{Template | align = top | margin = }} </pre> :One way around this that would handle both situations (completely absent and just a blank value) would be to use <code><nowiki>{{#ifeq:{{{align|}}}||<value if absent or blank>|<value if present and nonblank>}}</nowiki></code>. This comparison sets an empty string as the default, so if it is either not present or blank it will lead give the same result. * '''<nowiki></nowiki>''' - === Parser and Variable Functions === * '''<nowiki>{{AUTOINRCEMENT}}</nowiki>''' - A variable that increments by 1 each time used, see [[Help:Autoincrement]]. * '''<nowiki>#if:</nowiki>''' - <nowiki>{{#if: test string | value if true | value if false}}</nowiki> * '''<nowiki>#ifeq:</nowiki>''' - <nowiki>{{#ifeq: string 1 | string 2 | value if true | value if false}}</nowiki> - Compares string 1 with string 2 to see if they are equal. * '''<nowiki>#ifexist:</nowiki>''' - <nowiki>{{#ifexist: page title | value if exists | value if doesn't exist }}</nowiki>, can be used for articles or files (images). * '''<nowiki>#expr:</nowiki>''' - <nowiki>{{#expr: expression }}</nowiki> - Mathematical operations. [http://www.mediawiki.org/wiki/Help:Extension:ParserFunctions#.23expr: Details] * '''<nowiki>{{PAGESINCATEGORY}}</nowiki>''' - <nowiki>{{PAGESINCATEGORY:Page Name}}</nowiki> - Returns the number of pages in a category. Use <nowiki>{{PAGESINCATEGORY:Page Name|R}}</nowiki> for a number without commas. * '''<nowiki>#switch:</nowiki>''' - <nowiki>{{#switch:comparison string | case=result | case=result | default result }}</nowiki> - This function compares one input value against several test cases, returning an associated string if a match is found. [http://www.mediawiki.org/wiki/Help:Extension:ParserFunctions#.23switch: Details] * '''<nowiki>#titleparts:</nowiki>''' - <nowiki>{{#titleparts: pagename | number of segments to return | first segment to return }}</nowiki> - This function separates a pagetitle into segments based on slashes, then returns one or more of those segments as output. [http://www.mediawiki.org/wiki/Help:Extension:ParserFunctions#.23titleparts: Details] * '''<nowiki>#vardefine</nowiki>''' - <nowiki>{{#vardefine: variablename | value }}</nowiki> - assigns variable, see [[Help:Variables]]. * '''<nowiki>#vardefineecho</nowiki>''' - <nowiki>{{#vardefineecho: variablename | value }}</nowiki> - assigns and prints variable, see [[Help:Variables]]. * '''<nowiki>#var</nowiki>''' - <nowiki>{{#var: variablename }}</nowiki> - prints current value, see [[Help:Variables]]. == Request a Template == If you would like a template made but aren't sure how to go about adding one, [[User:Tlosk|Tlosk]] or [[User:Arkalor|Arkalor]] can probably help you. [[Category:Help]]
Summary:
Please note that all contributions to Sundering may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Sundering:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
If you're new to the wiki, please take a moment to review our
Naming Conventions
and
Page Templates
. Using proper article names and image formats/sizes keep the wiki clean and helps avoid duplicate entries. Thanks!
Template used on this page:
Template:Tl
(
edit
)