Help:Templates: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(Put short TOC on the left, full TOC on the right. Works now because ExpandBox no longer clears=both.)
(Used dark <pre> style to give headlines a chance to stand out. Undid substitution of {{KV BaseEntity}}. Added and used Template:Expand. Used some Template:tl. Added {{not}} to section Per-Game templates. Other beautifying (or so).)
Line 20: Line 20:
To add a template to a page (which is called ''transcluding''), simply type <code>{{</code>, the name of the template, and then <code>}}</code>. If you wish to add any parameters, put a <code>|</code> between the template's name and the <code>}}</code>, and define the parameters there. All parameters you define need to be separated by another <code>|</code>.
To add a template to a page (which is called ''transcluding''), simply type <code>{{</code>, the name of the template, and then <code>}}</code>. If you wish to add any parameters, put a <code>|</code> between the template's name and the <code>}}</code>, and define the parameters there. All parameters you define need to be separated by another <code>|</code>.


{{note|Any page can be transcluded by another one actually. Below is a transclusion of the [[Main Page]] using <code><nowiki>{{ExpandBox|{{:Main Page}}}}</nowiki></code>:}}
{{note|Any page can be transcluded by another one actually. Below is a transclusion of the [[Main Page]] using <code><nowiki>{{Expand|{{:Main Page}}}}</nowiki></code>:}}
{{ExpandBox|{{:Main Page}}}}
{{Expand|{{:Main Page}}}}


===Examples===
===Examples===
Here's a template where we don't define any parameters, you just drop it right in.
Here's a template where we don't define any parameters, you just drop it right in.
<pre>{{restart}}</pre>
<pre style="background-color:#444;border-color:#666;color:#ddd">{{restart}}</pre>
Result: {{restart}}
Result: {{restart}}


Line 32: Line 32:


The [[Template:Ent|ent]] template is a template that can accept up to two ''unnamed'' parameters.
The [[Template:Ent|ent]] template is a template that can accept up to two ''unnamed'' parameters.
<pre>{{ent|sv_cheats|1}}</pre>
<pre style="background-color:#444;border-color:#666;color:#ddd">{{ent|sv_cheats|1}}</pre>
Result: {{ent|sv_cheats|1}}
Result: {{ent|sv_cheats|1}}


Line 39: Line 39:


[[Template:KV|KV]] is one of the most common templates used. It accepts an optional ''named'' parameter (<code>since</code>).
[[Template:KV|KV]] is one of the most common templates used. It accepts an optional ''named'' parameter (<code>since</code>).
<pre>{{KV|Script think function (thinkfunction)|string|Name of a function in this entity's script which will be called automatically every 100 milliseconds (ten times a second) for the duration of the script. It can be used to create timers or to simulate autonomous behavior. The return value (if present) will set the time until the next call.|since=l4d2}}</pre>
<pre style="background-color:#444;border-color:#666;color:#ddd">{{KV|Script think function (thinkfunction)|string|Name of a function in this entity's script which will be called automatically every 100 milliseconds (ten times a second) for the duration of the script. It can be used to create timers or to simulate autonomous behavior. The return value (if present) will set the time until the next call.|since=l4d2}}</pre>
Result: {{KV|Script think function (thinkfunction)|string|Name of a function in this entity's script which will be called automatically every 100 milliseconds (ten times a second) for the duration of the script. It can be used to create timers or to simulate autonomous behavior. The return value (if present) will set the time until the next call.|since=l4d2}}
Result: {{KV|Script think function (thinkfunction)|string|Name of a function in this entity's script which will be called automatically every 100 milliseconds (ten times a second) for the duration of the script. It can be used to create timers or to simulate autonomous behavior. The return value (if present) will set the time until the next call.|since=l4d2}}
Without the <code>|since=l4d2</code> at the end, the {{l4d2 add}} message would not have displayed. Named parameters can be defined in any order.
Without the <code>|since=l4d2</code> at the end, the {{l4d2 add}} message would not have displayed. Named parameters can be defined in any order.
Line 47: Line 47:
===Substitution (for advanced users)===
===Substitution (for advanced users)===
Instead of transcluding a template, one can choose to ''substitute'' it. Substitution will replace a template with the contents ''of'' the template directly onto the page. To substitute a template, transclude it like you normally would, then add <code>subst:</code> between <code>{{</code> and the template's name. After that, click the save button and the wikitext will automatically be added. Do not substitute carelessly, because the substituted wikitext will not be updated when the template is. See [[Wikipedia:Help:Substitution]] for more information.
Instead of transcluding a template, one can choose to ''substitute'' it. Substitution will replace a template with the contents ''of'' the template directly onto the page. To substitute a template, transclude it like you normally would, then add <code>subst:</code> between <code>{{</code> and the template's name. After that, click the save button and the wikitext will automatically be added. Do not substitute carelessly, because the substituted wikitext will not be updated when the template is. See [[Wikipedia:Help:Substitution]] for more information.
<pre>{{subst:delete|This is a bad page.}}</pre>
<pre style="background-color:#444;border-color:#666;color:#ddd">{{subst:delete|This is a bad page.}}</pre>
When the page is saved, that text will be replaced with this:
When the page is saved, that text will be replaced with this:
<pre>{{Delete-meta|{{#if: This is a bad page. | This is a bad page. }} }}[[Category:Candidates for speedy deletion]]</pre>
<pre style="background-color:#444;border-color:#666;color:#ddd">{{Delete-meta|{{#if: This is a bad page. | This is a bad page. }} }}[[Category:Candidates for speedy deletion]]</pre>
Note the automatic forwarding of parameters. When substituting, the page should not appear any differently than it would if transcluded. The only difference is in the page code.
Note the automatic forwarding of parameters. When substituting, the page should not appear any differently than it would if transcluded. The only difference is in the page code.


Line 61: Line 61:


Here's part of the code for [[Template:Tip]]:
Here's part of the code for [[Template:Tip]]:
<pre>Tip:{{{1}}}</pre>
<pre style="background-color:#444;border-color:#666;color:#ddd">Tip:{{{1}}}</pre>
If you've seen this template before you know that it has its own special look, but this is all we will look at for now. All the user has to do when transcluding this is enter the text they want:
If you've seen this template before you know that it has its own special look, but this is all we will look at for now. All the user has to do when transcluding this is enter the text they want:
<pre>{{tip|Do not carve without vertex editing afterward.}}</pre>
<pre style="background-color:#444;border-color:#666;color:#ddd">{{tip|Do not carve without vertex editing afterward.}}</pre>
Result: {{tip|Do not carve without vertex editing afterward.}}
Result: {{tip|Do not carve without vertex editing afterward.}}


If you want to add more than one unnamed parameter, simply change the number. Here's the old (condensed) code for [[Template:Distinguish]]:
If you want to add more than one unnamed parameter, simply change the number. Here's the old (condensed) code for [[Template:Distinguish]]:
<pre>:''Not to be confused with [[:{{{1}}}]]{{#if:{{{2|}}} |{{#if:{{{3|}}} |, [[:{{{2}}}]]|&nbsp;or [[:{{{2}}}]].}}|.}}{{#if:{{{3|}}} |{{#if:{{{4|}}} |, [[:{{{3}}}]]|, or [[:{{{3}}}]].}}}}{{#if:{{{4|}}} |, or [[:{{{4}}}]].}}''</pre>
<pre style="background-color:#444;border-color:#666;color:#ddd">:''Not to be confused with [[:{{{1}}}]]{{#if:{{{2|}}} |{{#if:{{{3|}}} |, [[:{{{2}}}]]|&nbsp;or [[:{{{2}}}]].}}|.}}{{#if:{{{3|}}} |{{#if:{{{4|}}} |, [[:{{{3}}}]]|, or [[:{{{3}}}]].}}}}{{#if:{{{4|}}} |, or [[:{{{4}}}]].}}''</pre>
This template has some things we haven't talked about yet, but you can still see that there's four unnamed parameters used: <code>{{{1}}}</code>, <code>{{{2}}}</code>, <code>{{{3}}}</code>, and <code>{{{4}}}</code>.
This template has some things we haven't talked about yet, but you can still see that there's four unnamed parameters used: <code>{{{1}}}</code>, <code>{{{2}}}</code>, <code>{{{3}}}</code>, and <code>{{{4}}}</code>.


All the user has to do when transcluding is this:
All the user has to do when transcluding is this:
<pre>{{distinguish|Combine|Civil Protection|Overwatch}}</pre>
<pre style="background-color:#444;border-color:#666;color:#ddd">{{distinguish|Combine|Civil Protection|Overwatch}}</pre>
Result: {{distinguish|Combine|Civil Protection|Overwatch}}
Result: {{distinguish|Combine|Civil Protection|Overwatch}}


Line 78: Line 78:


With named parameter:
With named parameter:
<pre>{{IO|SetString|Updates the string.|param=string}}</pre>
<pre style="background-color:#444;border-color:#666;color:#ddd">{{IO|SetString|Updates the string.|param=string}}</pre>
Result: {{IO|SetString|Updates the string.|param=string}}
Result: {{IO|SetString|Updates the string.|param=string}}




Without named parameter:
Without named parameter:
<pre>{{IO|SetString|Updates the string.}}</pre>
<pre style="background-color:#444;border-color:#666;color:#ddd">{{IO|SetString|Updates the string.}}</pre>
Result: {{IO|SetString|Updates the string.}}
Result: {{IO|SetString|Updates the string.}}


===Default value===
===Default value===
To make a parameter have a value by default, add a <code>|</code> to the right of the parameter name, and then define the value. Named ''and'' unnamed parameters can use this.
To make a parameter have a value by default, add a <code>|</code> to the right of the parameter name, and then define the value. Named ''and'' unnamed parameters can use this.
<pre>{{{1|3000}}}</pre>
<pre style="background-color:#444;border-color:#666;color:#ddd">{{{1|3000}}}</pre>
This would make the value for <code>1</code> {{{1|3000}}}.
This would make the value for <code>1</code> {{{1|3000}}}.
<pre>{{{value|}}}</pre>
<pre style="background-color:#444;border-color:#666;color:#ddd">{{{value|}}}</pre>
This returns nothing. Without the <code>|</code>, it would literally return "{{{value}}}" as text, if it hasn't already been defined at some other point.
This returns nothing. Without the <code>|</code>, it would literally return "{{{value}}}" as text, if it hasn't already been defined at some other point.


===Parser Functions===
===Parser Functions===
<code>#if:</code> checks if a string or parameter has anything inside it.
<code>#if:</code> checks if a string or parameter has anything inside it.
<pre>{{#if: {{{target|}}} | Target aqcuired | Sleep mode activated... }}</pre>
<pre style="background-color:#444;border-color:#666;color:#ddd">{{#if: {{{target|}}} | Target aqcuired | Sleep mode activated... }}</pre>
Result: {{#if: {{{target|}}} | Target aqcuired | Sleep mode activated... }} ''(The parameter <code><nowiki>{{{target|}}}</nowiki></code> returns null because you (probably) are not viewing this page through a transclusion, so it's never had a chance to be defined.)''
Result: {{#if: {{{target|}}} | Target aqcuired | Sleep mode activated... }} ''(The parameter <code><nowiki>{{{target|}}}</nowiki></code> returns null because you (probably) are not viewing this page through a transclusion, so it's never had a chance to be defined.)''
<pre>{{#if: Something is there! | Target aqcuired | Sleep mode activated... }}</pre>
<pre style="background-color:#444;border-color:#666;color:#ddd">{{#if: Something is there! | Target aqcuired | Sleep mode activated... }}</pre>
Result: {{#if: Something is there! | Target aqcuired | Sleep mode activated... }}
Result: {{#if: Something is there! | Target aqcuired | Sleep mode activated... }}




<code>#ifeq:</code> checks for equality between two strings. It can be used with parameters as well.
<code>#ifeq:</code> checks for equality between two strings. It can be used with parameters as well.
<pre>{{#ifeq: {{{target|}}} | friend | Friend... | Go away! }}</pre>
<pre style="background-color:#444;border-color:#666;color:#ddd">{{#ifeq: {{{target|}}} | friend | Friend... | Go away! }}</pre>
Result: {{#ifeq: {{{target|}}} | friend | Friend... | Go away! }}
Result: {{#ifeq: {{{target|}}} | friend | Friend... | Go away! }}
<pre>{{#ifeq: friend | friend | Friend... | Go away! }}</pre>
<pre style="background-color:#444;border-color:#666;color:#ddd">{{#ifeq: friend | friend | Friend... | Go away! }}</pre>
Result: {{#ifeq: friend | friend | Friend... | Go away! }}
Result: {{#ifeq: friend | friend | Friend... | Go away! }}




<code>#expr:</code> solves math problems.
<code>#expr:</code> solves math problems.
<pre>{{#expr: 2 + 2}}</pre>
<pre style="background-color:#444;border-color:#666;color:#ddd">{{#expr: 2 + 2}}</pre>
Result: {{#expr: 2 + 2}}
Result: {{#expr: 2 + 2}}


Line 116: Line 116:


<code>#ifexpr:</code> tells if a math expression is correct.
<code>#ifexpr:</code> tells if a math expression is correct.
<pre>{{#ifexpr: 6 + 3 = 9 | Right | Wrong }}</pre>
<pre style="background-color:#444;border-color:#666;color:#ddd">{{#ifexpr: 6 + 3 = 9 | Right | Wrong }}</pre>
Result: {{#ifexpr: 6 + 3 = 9 | Right | Wrong }}
Result: {{#ifexpr: 6 + 3 = 9 | Right | Wrong }}
<pre>{{#ifexpr: 6 + 3 = 23 | Right | Wrong }}</pre>
<pre style="background-color:#444;border-color:#666;color:#ddd">{{#ifexpr: 6 + 3 = 23 | Right | Wrong }}</pre>
Result: {{#ifexpr: 6 + 3 = 23 | Right | Wrong }}
Result: {{#ifexpr: 6 + 3 = 23 | Right | Wrong }}


===Documentation===
===Documentation===
Please give a description of what your template is, and maybe examples. To keep this describing text from appearing on pages, there are 3 different HTML tags you can use.
Please give a description of what your template is, and maybe examples. To keep this describing text from appearing on pages that use the template, there are 3 different HTML tags you can use.
 
* <code><nowiki><noinclude>...</noinclude></nowiki></code> makes wikitext inside it not appear on the destination page, while keeping it on the template's page.
<code>noinclude</code> keeps wikitext inside it from appearing on the destination page, while keeping it on the source page.
* <code><nowiki><onlyinclude>...</onlyinclude></nowiki></code> makes only wikitext inside it appear on destination pages. Text not inside these will still appear on the template's page.
 
* <code><nowiki><includeonly>...</includeonly></nowiki></code> makes wikitext inside it not appear on the template page. It has no effect on the destination page.
<code>onlyinclude</code> makes only wikitext inside it appear on destination pages. Text not inside these will still appear on the template's page.
 
<code>includeonly</code> wikitext inside this will not appear on the template page. It has no effect on the destination page however.


They can sound very confusing at first. If you're confused on how to use them, check the source code for a template, because almost all use them for one purpose or another.
They can sound very confusing at first. If you're confused on how to use them, check the source code for a template, because almost all use them for one purpose or another.
Line 142: Line 139:


===Per-game templates===
===Per-game templates===
All games have templates that show their associated icon. (e.g. {{hl2}}) See [[:Category:Game icons]] for the full list. [[Template:Game link]] is a template that automatically links to a game's page and displays its icon next to it. (e.g. {{Game link|Half-Life 2}})
All games have templates that show their associated icon, e.g. <code><nowiki>{{hl2}}</nowiki></code> delivers: {{hl2}}. See [[:Category:Game icons]] or {{tl|game icon name}} for the full list.
 
* {{tl|Game link}} automatically links to a game's page and displays its icon next to it, e.g. <code><nowiki>{{Game link|Half-Life 2}}</nowiki></code> delivers: {{Game link|Half-Life 2}}.
The <nowiki>{{since}}</nowiki> template can be used to quickly note features that were added in a game and are available in all Source games afterwards (e.g. {{since|{{portal2}}}}) The <nowiki>{{only}}</nowiki> template indicates features that are exclusive to a specific game (e.g. {{only|{{csgo}}}}).
* {{tl|Game name}} does the same but is more colorful and needs another parameter, e.g. <code><nowiki>{{Game name|hl2|name=Half-Life 2}}</nowiki></code> delivers: {{Game name|hl2|name=Half-Life 2}}.
* {{tl|since}} can be used to quickly note features that were added in a game and are available in all Source games afterwards, e.g. <code><nowiki>{{since|{{portal2}}}}</nowiki></code> delivers: {{since|{{portal2}}}}.
* {{tl|only}} indicates features that are exclusive to a specific game, e.g. <code><nowiki>{{only|{{csgo}}}}</nowiki></code> delivers: {{only|{{csgo}}}}.
* {{tl|also}} notes that earlier game also has a feature, usually backported from newer engine branches. These should be used with in conjunction with another game notice template, e.g. {{only|{{L4d}}}} {{also|{{GMOD}}}} or {{since|{{as}}}} {{also|{{GMOD}}}}.
* {{tl|removed}} indicates that a feature was removed in a game and all later engine branches, e.g. <code><nowiki>{{removed|{{L4d}}}}</nowiki></code> delivers: {{removed|{{L4d}}}}.
* {{tl|not}} indicates that a feature might be in other games but not in a specific one, e.g. <code><nowiki>{{not|{{czds}}}}</nowiki></code> delivers: {{not|{{czds}}}}.


The <nowiki>{{also}}</nowiki> template notes that earlier game also has a feature, usually backported from newer engine branches. These should be used with in conjunction with another game notice template (e.g. {{only|{{L4d}}}} {{also|{{GMOD}}}} or {{since|{{as}}}} {{also|{{GMOD}}}}).
=== = ===
 
The <nowiki>{{removed}}</nowiki> template indicates that a feature was removed in a game and all later engine branches (e.g. {{removed|{{L4d}}}}).
 
=======
[[Template:=]] is a template that only returns an equal sign. The character is sometimes needed because multiple wiki features make use of it. An equal sign generated through this will never be counted as formatting.
[[Template:=]] is a template that only returns an equal sign. The character is sometimes needed because multiple wiki features make use of it. An equal sign generated through this will never be counted as formatting.


===bug===
===bug===
[[Template:Bug]] notifies readers of a [[Wikipedia:Software bug|bug]].
[[Template:Bug]] notifies readers of a [[Wikipedia:Software bug|bug]].
<pre>{{bug|The amount is double what it should be. Be careful!}}</pre>
<pre style="background-color:#444;border-color:#666;color:#ddd">{{bug|The amount is double what it should be. Be careful!}}</pre>
Result: {{bug|The amount is double what it should be. Be careful!}}
Result: {{bug|The amount is double what it should be. Be careful!}}


===clarify===
===clarify===
[[Template:Clarify]] marks things that should be clarified.
[[Template:Clarify]] marks things that should be clarified.
<pre>PAS is a kind of bounding-box for Player or NPC AI sound detection.{{clarify}}</pre>
<pre style="background-color:#444;border-color:#666;color:#ddd">PAS is a kind of bounding-box for Player or NPC AI sound detection.{{clarify}}</pre>
Result: PAS is a kind of bounding-box for Player or NPC AI sound detection.{{clarify}}
Result: PAS is a kind of bounding-box for Player or NPC AI sound detection.{{clarify}}


===cleanup===
===cleanup===
[[Template:Cleanup]] marks a page that needs to be fixed up, preferably by someone knowledgeable. The text message is optional. If you do not give sufficient reason for the notice on the transclusion or the talk page, expect it to be removed by someone else.
[[Template:Cleanup]] marks a page that needs to be fixed up, preferably by someone knowledgeable. The text message is optional. If you do not give sufficient reason for the notice on the transclusion or the talk page, expect it to be removed by someone else.
<pre>{{cleanup|The last section needs to be clarified.}}</pre>
<pre style="background-color:#444;border-color:#666;color:#ddd">{{cleanup|The last section needs to be clarified.}}</pre>
Result: {{messagebox
Result: {{messagebox
|text = This article needs to be '''cleaned up''' to conform to a higher standard of quality because:''' <p style="font-style: italic;">The last section needs to be clarified.</p>
|text = This article needs to be '''cleaned up''' to conform to a higher standard of quality because:''' <p style="font-style: italic;">The last section needs to be clarified.</p>
Line 174: Line 172:


===clr===
===clr===
[[Template:Clr]] clears the vertical space to the left or right of something. This is commonly used for making headlines not get moved around by images.
[[Template:Clr]] clears the vertical space to the left and right of floating tables, floating images etc. To clear only the left or only the right side, use <code><nowiki>{{clr|left}}</nowiki></code> or <code><nowiki>{{clr|right}}</nowiki></code>. This is commonly used for making headlines not get moved around by images.
 
{| class=wikitable width=100%
|
[[File:Skull and crossbones.png|50px|frameless|left]]
[[File:Skull and crossbones.png|50px|frameless|left]]
This text should appear next to the image. If you put <code><nowiki>{{clr}}</nowiki></code> right after this,
This text should appear next to the image. If you put <code><nowiki>{{clr}}</nowiki></code> right after this,


this bit of text here will get moved down.
this bit of text here will get moved down right under the image.
----
|
[[File:Skull and crossbones.png|50px|frameless|left]]
[[File:Skull and crossbones.png|50px|frameless|left]]
This text should appear next to the image. If you put <code><nowiki>{{clr}}</nowiki></code> right after this,{{clr}}


This text should appear next to the image. If you put <code><nowiki>{{clr}}</nowiki></code> right after this,{{clr}}
this bit of text here will get moved down right under the image.
|}


this bit of text here will get moved down.


===confirm===
===confirm===
[[Template:Confirm]] marks something that needs to be confirmed. It's green color is meant to stand out.
[[Template:Confirm]] marks something that needs to be confirmed. It's green color is meant to stand out.
<pre>{{confirm|Always goes to the left.}}</pre>
<pre style="background-color:#444;border-color:#666;color:#ddd">{{confirm|Always goes to the left.}}</pre>
Result: {{#if: Always goes to the left. | <div style="margin:0.4em 1em 0.5em;"><strong style="color:#8BC53F;display:table-cell;text-align:right;white-space:nowrap;padding-right:0.3em;">[[File:Confirm.png|link=|alt=]] Confirm:</strong><span style="display:table-cell;">Always goes to the left.</span></div> | <sup style="color:#8BC53F;">&#91;''confirm''&#93;</sup> }}
Result: {{#if: Always goes to the left. | <div style="margin:0.4em 1em 0.5em;"><strong style="color:#8BC53F;display:table-cell;text-align:right;white-space:nowrap;padding-right:0.3em;">[[File:Confirm.png|link=|alt=]] Confirm:</strong><span style="display:table-cell;">Always goes to the left.</span></div> | <sup style="color:#8BC53F;">&#91;''confirm''&#93;</sup> }}
<pre>Always goes to the left.{{confirm}}</pre>
<pre style="background-color:#444;border-color:#666;color:#ddd">Always goes to the left.{{confirm}}</pre>
Result: Always goes to the left.{{#if:  | <div style="margin:0.4em 1em 0.5em;"><strong style="color:#8BC53F;display:table-cell;text-align:right;white-space:nowrap;padding-right:0.3em;">[[File:Confirm.png|link=|alt=]] Confirm:</strong><span style="display:table-cell;">{{{1}}}</span></div> | <sup style="color:#8BC53F;">&#91;''confirm''&#93;</sup> }}
Result: Always goes to the left.{{#if:  | <div style="margin:0.4em 1em 0.5em;"><strong style="color:#8BC53F;display:table-cell;text-align:right;white-space:nowrap;padding-right:0.3em;">[[File:Confirm.png|link=|alt=]] Confirm:</strong><span style="display:table-cell;">{{{1}}}</span></div> | <sup style="color:#8BC53F;">&#91;''confirm''&#93;</sup> }}


===delete===
===delete===
[[Template:Delete]] marks a page that should be deleted. If you do not give sufficient reason for the notice on the transclusion or the talk page, expect it to be removed by someone else. When putting this on a page, you should also list the reason on that page's talk page, for any future readers that may want to know the purpose of the deletion.
[[Template:Delete]] marks a page that should be deleted. If you do not give sufficient reason for the notice on the transclusion or the talk page, expect it to be removed by someone else. When putting this on a page, you should also list the reason on that page's talk page, for any future readers that may want to know the purpose of the deletion.
<pre>{{delete|This is not a real thing.}}</pre>
<pre style="background-color:#444;border-color:#666;color:#ddd">{{delete|This is not a real thing.}}</pre>
Result: {{messagebox
Result: {{messagebox
|text = '''This page is a [[Help:Deletion|candidate for speedy deletion]]{{#if: {{#if: This is not a real thing. | This is not a real thing. }}  | &nbsp;because:''' <p style="font-style: italic;">{{#if: This is not a real thing. | This is not a real thing. }} </p>| .''' }}
|text = '''This page is a [[Help:Deletion|candidate for speedy deletion]]{{#if: {{#if: This is not a real thing. | This is not a real thing. }}  | &nbsp;because:''' <p style="font-style: italic;">{{#if: This is not a real thing. | This is not a real thing. }} </p>| .''' }}
Line 212: Line 211:


Example from [[Follow Freeman]]:
Example from [[Follow Freeman]]:
<pre>{{distinguish|"Follow Freeman!"|desc1=The HL2 chapter}}</pre>
<pre style="background-color:#444;border-color:#666;color:#ddd">{{distinguish|"Follow Freeman!"|desc1=The HL2 chapter}}</pre>
Result: {{distinguish|"Follow Freeman!"|desc1=The HL2 chapter}}
Result: {{distinguish|"Follow Freeman!"|desc1=The HL2 chapter}}


===ent===
===ent===
[[Template:Ent]] is a really small template for making text that's both code and a link.
[[Template:Ent]] is a really small template for making text that's both code and a link.
<pre>{{ent|noclip}}</pre>
<pre style="background-color:#444;border-color:#666;color:#ddd">{{ent|noclip}}</pre>
Result: {{ent|noclip}}
Result: {{ent|noclip}}


===ExpandBox===
===Expand/ExpandBox===
[[Template:ExpandBox]] allows you to hide stuff inside a box that can be shrunk down so that it doesn't make pages as long.
[[Template:Expand]] or [[Template:ExpandBox]] allows you to hide stuff inside a box that can be shrunk down so that it doesn't make pages as long.
<pre>{{ExpandBox|{{:KV BaseEntity}}}}</pre>
<pre style="background-color:#444;border-color:#666;color:#ddd">{{Expand|{{KV BaseEntity|noscroll=1}}}}</pre>
Result: {{ExpandBox|{{KV|Classname (classname)|string|The [[classname]] defines the type of entity.}}
Result: {{Expand|{{KV BaseEntity|noscroll=1}}}} <!-- doesn't inherit Categories, no need to subst: -->
:{{note|Classnames can be changed using [[AddOutput]], which will influence how the engine deals with the entity in certain circumstances.}}
<pre style="background-color:#444;border-color:#666;color:#ddd">{{ExpandBox|{{KV BaseEntity|noscroll=1}}}}</pre>
{{KV|Name (targetname)|string|The [[targetname]] that other entities refer to this entity by. }}
Result: {{ExpandBox|{{KV BaseEntity|noscroll=1}}}}
{{KV|Global Entity Name (globalname)|string|Name by which this entity is linked to another entity in a different map. When the player transitions to a new map, entities in the new map with globalnames matching entities in the previous map will have the previous map's state copied over their state.}}
{{KV|Parent (parentname)|targetname|Specifies a [[Entity Hierarchy (parenting)|movement parent]]. An entity will maintain its initial offset from its parent. An attachment point can be added to the end of the name, separated by a comma.
:{{note|''Every'' entity can be parented, even point entities. Some entities which aren't intended to be parented may not function correctly. [[phys_constraint]] can be used as a workaround to parenting.}}
{{#if:  | {{warning|If a trigger does not start out with a parent but rather is assigned one dynamically, choose another entity and add it here as a dummy. Otherwise the trigger will stop colliding properly when it gets its real parent.}} }}
{{#if:  | {{warning|In {{game link|Counter-Strike: Source}}, [[Counter-Strike Source Entity Overview#Counter-Strike Round Restarts|parenting this entity to another can break the map]].}} }} }}
{{KV|Origin {X Y Z} (origin)|origin|The position of this entity's center in the world. Rotating entities typically rotate around their origin.}}
{{KV|Pitch Yaw Roll {Y Z X}  (angles)|angle|This entity's orientation in the world. Pitch is rotation around the Y axis, yaw is the rotation around the Z axis, roll is the rotation around the X axis.}}
:{{note|This works on brush entities, although Hammer doesn't show the new angles.}}
{{KV|Hammer ID (hammerid)|string|The entity's [[Hammer]] ID. Mainly used by plugins and debugging commands, such as [[ent_keyvalue]].}} {{Not in FGD}}
{{KV|Effects (effects)|string|[[Effect flags]].}} {{Not in FGD}}
{{KV|Response Contexts (ResponseContext)|string|Pre-defined [[Response System|response system]] contexts for this entity. Format is <code>key:value,key:value,...</code>}}
:{{note|Despite the description, this works for ''all'' entities, although it is missing from most entities in the FGD.}}
{{#if:|
{{KV|Minimum CPU Level (mincpulevel)|int|Minimum CPU Level allowed for this entity. 0 means all levels allowed. {{not in FGD}}|since=L4D}}
{{KV|Maximum CPU Level (maxcpulevel)|int|Maximum CPU Level allowed for this entity. 0 means all levels allowed. {{not in FGD}}|since=L4D}}
{{KV|Minimum GPU Level (mingpulevel)|int|Minimum GPU Level allowed for this entity. 0 means all levels allowed. {{not in FGD}}|since=L4D}}
{{KV|Maximum GPU Level (maxgpulevel)|int|Maximum GPU Level allowed for this entity. 0 means all levels allowed. {{not in FGD}}|since=L4D}}
:<strong style="color:#8BC53F;white-space:nowrap;">To do{{#if: Better description for all of these. | &#58;&nbsp; }}</strong>Better description for all of these.
{{KV|Disable for Xbox 360 (disableX360)|bool|If Yes, disables this entity on the Xbox 360 version of Source. {{not in FGD}}|since=L4D}}
:{{#if: Playstation 3? | <div style="margin:0.4em 1em 0.5em;"><strong style="color:#8BC53F;display:table-cell;text-align:right;white-space:nowrap;padding-right:0.3em;">[[File:Confirm.png|link=|alt=]] Confirm:</strong><span style="display:table-cell;">Playstation 3?</span></div> | <sup style="color:#8BC53F;">&#91;''confirm''&#93;</sup> }}
| }}{{#if:||{{#if:||
{{KV|Minimum CPU Level (mincpulevel)|int|Minimum CPU Level allowed for this entity. 0 means all levels allowed. {{not in FGD}}|since=L4D}}
{{KV|Maximum CPU Level (maxcpulevel)|int|Maximum CPU Level allowed for this entity. 0 means all levels allowed. {{not in FGD}}|since=L4D}}
{{KV|Minimum GPU Level (mingpulevel)|int|Minimum GPU Level allowed for this entity. 0 means all levels allowed. {{not in FGD}}|since=L4D}}
{{KV|Maximum GPU Level (maxgpulevel)|int|Maximum GPU Level allowed for this entity. 0 means all levels allowed. {{not in FGD}}|since=L4D}}
:<strong style="color:#8BC53F;white-space:nowrap;">To do{{#if: Better description for all of these. | &#58;&nbsp; }}</strong>Better description for all of these.
{{KV|Disable for Xbox 360 (disableX360)|bool|If Yes, disables this entity on the Xbox 360 version of Source. {{not in FGD}}|since=L4D}}
:{{#if: Playstation 3? | <div style="margin:0.4em 1em 0.5em;"><strong style="color:#8BC53F;display:table-cell;text-align:right;white-space:nowrap;padding-right:0.3em;">[[File:Confirm.png|link=|alt=]] Confirm:</strong><span style="display:table-cell;">Playstation 3?</span></div> | <sup style="color:#8BC53F;">&#91;''confirm''&#93;</sup> }}
}}}}
{{#if:|
{{KV|Glow Backface Multiple (glowbackfacemult)|string|Unknown. {{l4d2}} only. {{not in FGD}}|since=L4D2}}
:<strong style="color:#8BC53F;white-space:nowrap;">To do{{#if: Documentation. | &#58;&nbsp; }}</strong>Documentation.
{{KV|Entity Scripts (vscripts)|scriptlist|Space delimited list of [[VScript]] files (without file extension) that are executed after all entities have spawned. The scripts are all executed in the same script scope, later ones overwriting any identical variables and functions. |since=L4D2}}
{{KV|Script think function (thinkfunction)|string|Name of a function in this entity's script which will be called automatically every 100 milliseconds (ten times a second) for the duration of the script. It can be used to create timers or to simulate autonomous behavior. The return value (if present) will set the time until the next call. {{note|Try to avoid expensive operations in this function, as it may cause performance problems.}}|since=L4D2}}
| }}{{#if:||{{#if:||
{{KV|Glow Backface Multiple (glowbackfacemult)|string|Unknown. {{l4d2}} only. {{not in FGD}}|since=L4D2}}
:<strong style="color:#8BC53F;white-space:nowrap;">To do{{#if: Documentation. | &#58;&nbsp; }}</strong>Documentation.
{{KV|Entity Scripts (vscripts)|scriptlist|Space delimited list of [[VScript]] files (without file extension) that are executed after all entities have spawned. The scripts are all executed in the same script scope, later ones overwriting any identical variables and functions. |since=L4D2}}
{{KV|Script think function (thinkfunction)|string|Name of a function in this entity's script which will be called automatically every 100 milliseconds (ten times a second) for the duration of the script. It can be used to create timers or to simulate autonomous behavior. The return value (if present) will set the time until the next call. {{note|Try to avoid expensive operations in this function, as it may cause performance problems.}}|since=L4D2}}
}}}}
{{KV|Lag Compensation (LagCompensate)|boolean|Set to Yes to lag compensate this entity. Should be used very sparingly!|since=AS}}
{{#if:|
{{KV|Is Automatic-Aim Target (is_autoaim_target)|bool|If yes, automatic-aim assistance will target this entity. {{not in FGD}}|since=CSGO}}
| }}{{#if:||{{#if:||
{{KV|Is Automatic-Aim Target (is_autoaim_target)|bool|If yes, automatic-aim assistance will target this entity. {{not in FGD}}|since=CSGO}}
}}}}}}


===how===
===how===
[[Template:How]] asks the question ''how?''
[[Template:How]] asks the question ''how?''
<pre>Players can get past these.{{how}}</pre>
<pre style="background-color:#444;border-color:#666;color:#ddd">Players can get past these.{{how}}</pre>
Result: Players can get past these.{{how}}
Result: Players can get past these.{{how}}


===idea===
===idea===
[[Template:Idea]] is a nifty way to suggest ideas.
[[Template:Idea]] is a nifty way to suggest ideas.
<pre>{{idea|Reward players for being clever and creative, instead of forcing things to be only one way.}}</pre>
<pre style="background-color:#444;border-color:#666;color:#ddd">{{idea|Reward players for being clever and creative, instead of forcing things to be only one way.}}</pre>
Result: {{idea|Reward players for being clever and creative, instead of forcing things to be only one way.}}
Result: {{idea|Reward players for being clever and creative, instead of forcing things to be only one way.}}


===merge===
===merge===
[[Template:Merge]] is a notice that notifies editors that it's been suggested for two or more pages to be combined into one. All merges should be discussed before being done.
[[Template:Merge]] is a notice that notifies editors that it's been suggested for two or more pages to be combined into one. All merges should be discussed before being done.
<pre>{{merge|HDR}}</pre>
<pre style="background-color:#444;border-color:#666;color:#ddd">{{merge|HDR}}</pre>
Result: {{messagebox
Result: {{messagebox
|text = It has been suggested that this article or section be [[Wikipedia:Merging and moving pages|merged]] with ''[[HDR]]''. ([[talk:HDR|Discuss]])
|text = It has been suggested that this article or section be [[Wikipedia:Merging and moving pages|merged]] with ''[[HDR]]''. ([[talk:HDR|Discuss]])
Line 294: Line 247:
===messagebox===
===messagebox===
[[Template:Messagebox]] provides a standard message box. This template is used by many notice templates, such as merge and cleanup.
[[Template:Messagebox]] provides a standard message box. This template is used by many notice templates, such as merge and cleanup.
<pre>{{messagebox|text=Remember to follow wiki etiquette.}}</pre>
<pre style="background-color:#444;border-color:#666;color:#ddd">{{messagebox|text=Remember to follow wiki etiquette.}}</pre>
Result: {{messagebox|text=Remember to follow wiki etiquette.}}
Result: {{messagebox|text=Remember to follow wiki etiquette.}}


===morescreenshots===
===morescreenshots===
[[Template:Morescreenshots]] marks pages that should have more images on them. It allows for an optional text message to clarify what needs images.
[[Template:Morescreenshots]] marks pages that should have more images on them. It allows for an optional text message to clarify what needs images.
<pre>{{morescreenshots|$envmapcontrast, $envmapsaturation}}</pre>
<pre style="background-color:#444;border-color:#666;color:#ddd">{{morescreenshots|$envmapcontrast, $envmapsaturation}}</pre>
Result: {{messagebox
Result: {{messagebox
|text = This article or section needs additional screenshots for:'''<p style="font-style: italic;">$envmapcontrast, $envmapsaturation</p>| .
|text = This article or section needs additional screenshots for:'''<p style="font-style: italic;">$envmapcontrast, $envmapsaturation</p>| .
Line 310: Line 263:
[[Template:Note]] is for making notes stand out more.
[[Template:Note]] is for making notes stand out more.
{{bug|Appears to not accept HTML tags inside it...?}}
{{bug|Appears to not accept HTML tags inside it...?}}
<pre>{{note|This will spawn at the map origin if you do not specify the position.}}</pre>
<pre style="background-color:#444;border-color:#666;color:#ddd">{{note|This will spawn at the map origin if you do not specify the position.}}</pre>
Result: {{note|This will spawn at the map origin if you do not specify the position.}}
Result: {{note|This will spawn at the map origin if you do not specify the position.}}


===obsolete===
===obsolete===
[[Template:Obsolete]] marks things that should no longer be used. Accepts three parameters, entity, tool, and shader.
[[Template:Obsolete]] marks things that should no longer be used. Accepts three parameters, entity, tool, and shader.
<pre>{{obsolete|entity=1}}</pre>
<pre style="background-color:#444;border-color:#666;color:#ddd">{{obsolete|entity=1}}</pre>
Result: {{messagebox
Result: {{messagebox
|text = This entity is '''obsolete'''; its use is discouraged and it may only exist/function in older engine branches.
|text = This entity is '''obsolete'''; its use is discouraged and it may only exist/function in older engine branches.
Line 328: Line 281:
===shortcut===
===shortcut===
[[Template:Shortcut]] displays a small box noting (abbreviated) redirects to a page.
[[Template:Shortcut]] displays a small box noting (abbreviated) redirects to a page.
<pre>{{shortcut|VDC:AL}}</pre>
<pre style="background-color:#444;border-color:#666;color:#ddd">{{shortcut|VDC:AL}}</pre>
Result: {{shortcut|VDC:AL}}
Result: {{shortcut|VDC:AL}}


===spammer===
===spammer===
[[Template:Spammer]] marks users that should be banned for spamming. {{bug|This template's formatting may look weird sometimes. It's intended to be the only thing on a page.}}
[[Template:Spammer]] marks users that should be banned for spamming. {{bug|This template's formatting may look weird sometimes. It's intended to be the only thing on a page.}}
<pre>{{spammer}}</pre>
<pre style="background-color:#444;border-color:#666;color:#ddd">{{spammer}}</pre>
Result: [[File:Spammer.jpg|left]]
Result: [[File:Spammer.jpg|left]]
<div style="overflow:auto;">
<div style="overflow:auto;">
Line 345: Line 298:
===split-apart===
===split-apart===
[[Template:Split-apart]] marks pages that should be split into multiple pages. All splits should be discussed before being done.
[[Template:Split-apart]] marks pages that should be split into multiple pages. All splits should be discussed before being done.
<pre>{{split-apart}}</pre>
<pre style="background-color:#444;border-color:#666;color:#ddd">{{split-apart}}</pre>
Result:
Result:
{{messagebox
{{messagebox
Line 356: Line 309:
===stub===
===stub===
[[Template:Stub]] marks pages that are very small. See [[Help:Stubs]] for info on using.
[[Template:Stub]] marks pages that are very small. See [[Help:Stubs]] for info on using.
<pre>{{stub}}</pre>
<pre style="background-color:#444;border-color:#666;color:#ddd">{{stub}}</pre>
Result: {{messagebox
Result: {{messagebox
|text = This article is a [[Help:Stubs|stub]]. You can help by adding to it.
|text = This article is a [[Help:Stubs|stub]]. You can help by adding to it.
Line 364: Line 317:
===tip===
===tip===
[[Template:Tip]] marks text as a tip to readers.
[[Template:Tip]] marks text as a tip to readers.
<pre>{{tip|This is a much less tricky process when using the vertex edit tool as well.}}</pre>
<pre style="background-color:#444;border-color:#666;color:#ddd">{{tip|This is a much less tricky process when using the vertex edit tool as well.}}</pre>
Result: {{tip|This is a much less tricky process when using the vertex edit tool as well.}}
Result: {{tip|This is a much less tricky process when using the vertex edit tool as well.}}


Line 372: Line 325:
===todo===
===todo===
[[Template:Todo]] marks things that need to be done. It's green color is meant to stand out.
[[Template:Todo]] marks things that need to be done. It's green color is meant to stand out.
<pre>{{todo|Find where this is in the game files.}}</pre>
<pre style="background-color:#444;border-color:#666;color:#ddd">{{todo|Find where this is in the game files.}}</pre>
Result: <strong style="color:#8BC53F;white-space:nowrap;">To do{{#if: Find where this is in the game files. | &#58;&nbsp; }}</strong>Find where this is in the game files.
Result: <strong style="color:#8BC53F;white-space:nowrap;">To do{{#if: Find where this is in the game files. | &#58;&nbsp; }}</strong>Find where this is in the game files.


===unsigned===
===unsigned===
[[Template:Unsigned]] is for [[Help:Etiquette|talk pages]]. It should be added at the ends of unsigned comments.
[[Template:Unsigned]] is for [[Help:Etiquette|talk pages]]. It should be added at the ends of unsigned comments.
<pre>{{unsigned|JeffLane}}</pre>
<pre style="background-color:#444;border-color:#666;color:#ddd">{{unsigned|JeffLane}}</pre>
Result: {{unsigned|JeffLane}}
Result: {{unsigned|JeffLane}}


===update===
===update===
[[Template:Update]] marks outdated pages.
[[Template:Update]] marks outdated pages.
<pre>{{update}}</pre>
<pre style="background-color:#444;border-color:#666;color:#ddd">{{update}}</pre>
Result:  
Result:  
{{messagebox
{{messagebox
Line 391: Line 344:
===warning===
===warning===
[[Template:Warning]] marks things that readers should take caution of when doing something.
[[Template:Warning]] marks things that readers should take caution of when doing something.
<pre>{{warning|This tool has been known to corrupt files. Try an alternative listed below.}}</pre>
<pre style="background-color:#444;border-color:#666;color:#ddd">{{warning|This tool has been known to corrupt files. Try an alternative listed below.}}</pre>
Result: {{warning|This tool has been known to corrupt files. Try an alternative listed below.}}
Result: {{warning|This tool has been known to corrupt files. Try an alternative listed below.}}


===why===
===why===
[[Template:Why]] asks the question ''why?''
[[Template:Why]] asks the question ''why?''
<pre>This shader has been deprecated.{{why}}</pre>
<pre style="background-color:#444;border-color:#666;color:#ddd">This shader has been deprecated.{{why}}</pre>
Result: This shader has been deprecated.{{why}}
Result: This shader has been deprecated.{{why}}


===wip===
===wip===
[[Template:Wip]] marks pages that are in the middle of major edits. The adder requests that other users do not edit in the meantime.
[[Template:Wip]] marks pages that are in the middle of major edits. The adder requests that other users do not edit in the meantime.
<pre>{{WIP|~~~}}</pre>
<pre style="background-color:#444;border-color:#666;color:#ddd">{{WIP|~~~}}</pre>
Result:
Result:
{{messagebox
{{messagebox

Revision as of 03:17, 27 January 2022

English (en)Русский (ru)中文 (zh)Translate (Translate)
Help:Editing

Templates enable you to do things much faster and/or easier. Templates are used very frequently on pages, so it's best to learn about them. When the wiki sees a template it recognizes on a page, it will automatically replace it with something else. What appears there is up to the users.

1  How to use a template
2  Making templates
3  Templates not updating
4  Template shortcuts
5  Useful templates
6  Magic words
7  See Also

How to use a template

Before a template can be added somewhere, first its contents must be defined on its own page. Template pages should start with the prefix Template:.

Templates have some limited programming abilities, which gives them lots of possibilities. We'll talk more about those later.

To add a template to a page (which is called transcluding), simply type {{, the name of the template, and then }}. If you wish to add any parameters, put a | between the template's name and the }}, and define the parameters there. All parameters you define need to be separated by another |.

Note.pngNote:Any page can be transcluded by another one actually. Below is a transclusion of the Main Page using {{Expand|{{:Main Page}}}}:
English (en)Deutsch (de)Esperanto (eo)Español (es)Français (fr)Suomi (fi)Hrvatski (hr)Italiano (it)日本語 (ja)한국어 (ko)Nederlands (nl)Polski (pl)Português do Brasil (pt-br)Русский (ru)Slovenčina (sk)Svenska (sv)Türkçe (tr)Українська (uk)Tiếng Việt (vi)中文 (zh)中文(臺灣) (zh-tw)
Welcome to the
Valve Developer Community
13,096 articles documenting the development process.

Whether you're building a commercial project or a modification for Half-Life® 2, you'll want to sign up as a Valve developer today. It's free to join and is open to anyone working with the Source engine and its software development kit.

Examples

Here's a template where we don't define any parameters, you just drop it right in.

{{restart}}

Result: Requires restart to take effect.

If you visit this template's page, you'll see that its just those five words.


The ent template is a template that can accept up to two unnamed parameters.

{{ent|sv_cheats|1}}

Result: sv_cheats 1

Unnamed parameters must be defined in a specific order.


KV is one of the most common templates used. It accepts an optional named parameter (since).

{{KV|Script think function (thinkfunction)|string|Name of a function in this entity's script which will be called automatically every 100 milliseconds (ten times a second) for the duration of the script. It can be used to create timers or to simulate autonomous behavior. The return value (if present) will set the time until the next call.|since=l4d2}}

Result:

Script think function (thinkfunction) ([todo internal name (i)]) <string> (in all games since Left 4 Dead 2)
Name of a function in this entity's script which will be called automatically every 100 milliseconds (ten times a second) for the duration of the script. It can be used to create timers or to simulate autonomous behavior. The return value (if present) will set the time until the next call.

Without the |since=l4d2 at the end, the Template:L4d2 add message would not have displayed. Named parameters can be defined in any order.

Templates can also use templates (nesting). In the KV template above, the |since=l4d2 part adds {{l4d2 add}} into the page, which is the Template:L4d2 add message.

Substitution (for advanced users)

Instead of transcluding a template, one can choose to substitute it. Substitution will replace a template with the contents of the template directly onto the page. To substitute a template, transclude it like you normally would, then add subst: between {{ and the template's name. After that, click the save button and the wikitext will automatically be added. Do not substitute carelessly, because the substituted wikitext will not be updated when the template is. See Wikipedia:Help:Substitution for more information.

{{subst:delete|This is a bad page.}}

When the page is saved, that text will be replaced with this:

{{Delete-meta|{{#if: This is a bad page. | This is a bad page. }} }}[[Category:Candidates for speedy deletion]]

Note the automatic forwarding of parameters. When substituting, the page should not appear any differently than it would if transcluded. The only difference is in the page code.

Making templates

Making a template like Template:Restart is rather easy - just type the text you want, and save it. What about ones with parameters?

Tip.pngTip:When making templates, you may want to space out your code to make it easier to read, but watch out for unintentional whitespace. HTML comments (<!-- -->) can also be useful.

Unnamed parameters

To add an unnamed parameter, simply put {{{1}}} where you want it to be.

Here's part of the code for Template:Tip:

Tip:{{{1}}}

If you've seen this template before you know that it has its own special look, but this is all we will look at for now. All the user has to do when transcluding this is enter the text they want:

{{tip|Do not carve without vertex editing afterward.}}

Result:

Tip.pngTip:Do not carve without vertex editing afterward.

If you want to add more than one unnamed parameter, simply change the number. Here's the old (condensed) code for Template:Distinguish:

:''Not to be confused with [[:{{{1}}}]]{{#if:{{{2|}}} |{{#if:{{{3|}}} |, [[:{{{2}}}]]| or [[:{{{2}}}]].}}|.}}{{#if:{{{3|}}} |{{#if:{{{4|}}} |, [[:{{{3}}}]]|, or [[:{{{3}}}]].}}}}{{#if:{{{4|}}} |, or [[:{{{4}}}]].}}''

This template has some things we haven't talked about yet, but you can still see that there's four unnamed parameters used: {{{1}}}, {{{2}}}, {{{3}}}, and {{{4}}}.

All the user has to do when transcluding is this:

{{distinguish|Combine|Civil Protection|Overwatch}}

Result:

Not to be confused with Combine, Civil Protection or Overwatch.

Named parameters

Usually you would want to have named parameters affect anything only if they are defined when being transcluded. We'll talk about conditions later. For now, let's look at Template:IO, which has many named parameters. In this template, {{{param}}} marks a place to add wikitext that's defined by |param=texthere when transcluding.

With named parameter:

{{IO|SetString|Updates the string.|param=string}}

Result:

SetString <string>
Updates the string.


Without named parameter:

{{IO|SetString|Updates the string.}}

Result:

SetString
Updates the string.

Default value

To make a parameter have a value by default, add a | to the right of the parameter name, and then define the value. Named and unnamed parameters can use this.

{{{1|3000}}}

This would make the value for 1 3000.

{{{value|}}}

This returns nothing. Without the |, it would literally return "{{{value}}}" as text, if it hasn't already been defined at some other point.

Parser Functions

#if: checks if a string or parameter has anything inside it.

{{#if: {{{target|}}} | Target aqcuired | Sleep mode activated... }}

Result: Sleep mode activated... (The parameter {{{target|}}} returns null because you (probably) are not viewing this page through a transclusion, so it's never had a chance to be defined.)

{{#if: Something is there! | Target aqcuired | Sleep mode activated... }}

Result: Target aqcuired


#ifeq: checks for equality between two strings. It can be used with parameters as well.

{{#ifeq: {{{target|}}} | friend | Friend... | Go away! }}

Result: Go away!

{{#ifeq: friend | friend | Friend... | Go away! }}

Result: Friend...


#expr: solves math problems.

{{#expr: 2 + 2}}

Result: 4

See m:Help:Calculation for all it's abilities.


#ifexpr: tells if a math expression is correct.

{{#ifexpr: 6 + 3 = 9 | Right | Wrong }}

Result: Right

{{#ifexpr: 6 + 3 = 23 | Right | Wrong }}

Result: Wrong

Documentation

Please give a description of what your template is, and maybe examples. To keep this describing text from appearing on pages that use the template, there are 3 different HTML tags you can use.

  • <noinclude>...</noinclude> makes wikitext inside it not appear on the destination page, while keeping it on the template's page.
  • <onlyinclude>...</onlyinclude> makes only wikitext inside it appear on destination pages. Text not inside these will still appear on the template's page.
  • <includeonly>...</includeonly> makes wikitext inside it not appear on the template page. It has no effect on the destination page.

They can sound very confusing at first. If you're confused on how to use them, check the source code for a template, because almost all use them for one purpose or another.

Templates not updating

If you've recently edited a template and the changes are not applying on pages it's been transcluded to, add ?action=purge at the end of the URL for those pages. This will tell the server to update the page's HTML immediately. You can achieve the same effect by editing a page and saving it without making any changes.

Template shortcuts

Some templates may have template shortcuts, which are redirects that are abbreviated or otherwise different forms of their target templates. Template shortcuts can be transcluded just like their target templates.

Useful templates

All templates in green text are that color so that they stand out against the greyscale tones of most pages. Most templates with that color also automatically add pages they are transcluded on into Category:TODO.

Per-game templates

All games have templates that show their associated icon, e.g. {{hl2}} delivers: Half-Life 2. See Category:Game icons or {{game icon name}} for the full list.

  • {{Game link}} automatically links to a game's page and displays its icon next to it, e.g. {{Game link|Half-Life 2}} delivers: Half-Life 2 Half-Life 2 .
  • {{Game name}} does the same but is more colorful and needs another parameter, e.g. {{Game name|hl2|name=Half-Life 2}} delivers: Template:Game name.
  • {{since}} can be used to quickly note features that were added in a game and are available in all Source games afterwards, e.g. {{since|{{portal2}}}} delivers: (in all games since Portal 2).
  • {{only}} indicates features that are exclusive to a specific game, e.g. {{only|{{csgo}}}} delivers: (only in Counter-Strike: Global Offensive).
  • {{also}} notes that earlier game also has a feature, usually backported from newer engine branches. These should be used with in conjunction with another game notice template, e.g. (only in Left 4 Dead) (also in Garry's Mod) or (in all games since Alien Swarm) (also in Garry's Mod).
  • {{removed}} indicates that a feature was removed in a game and all later engine branches, e.g. {{removed|{{L4d}}}} delivers: (removed since Left 4 Dead).
  • {{not}} indicates that a feature might be in other games but not in a specific one, e.g. {{not|{{czds}}}} delivers: (not in Condition Zero Deleted Scenes).

=

Template:= is a template that only returns an equal sign. The character is sometimes needed because multiple wiki features make use of it. An equal sign generated through this will never be counted as formatting.

bug

Template:Bug notifies readers of a bug.

{{bug|The amount is double what it should be. Be careful!}}

Result:

Icon-Bug.pngBug:The amount is double what it should be. Be careful!  [todo tested in ?]

clarify

Template:Clarify marks things that should be clarified.

PAS is a kind of bounding-box for Player or NPC AI sound detection.{{clarify}}

Result: PAS is a kind of bounding-box for Player or NPC AI sound detection.[Clarify]

cleanup

Template:Cleanup marks a page that needs to be fixed up, preferably by someone knowledgeable. The text message is optional. If you do not give sufficient reason for the notice on the transclusion or the talk page, expect it to be removed by someone else.

{{cleanup|The last section needs to be clarified.}}

Result:

clr

Template:Clr clears the vertical space to the left and right of floating tables, floating images etc. To clear only the left or only the right side, use {{clr|left}} or {{clr|right}}. This is commonly used for making headlines not get moved around by images.

Skull and crossbones.png

This text should appear next to the image. If you put {{clr}} right after this,

this bit of text here will get moved down right under the image.

Skull and crossbones.png
This text should appear next to the image. If you put {{clr}} right after this,

this bit of text here will get moved down right under the image.


confirm

Template:Confirm marks something that needs to be confirmed. It's green color is meant to stand out.

{{confirm|Always goes to the left.}}

Result:

Confirm:Always goes to the left.
Always goes to the left.{{confirm}}

Result: Always goes to the left.[confirm]

delete

Template:Delete marks a page that should be deleted. If you do not give sufficient reason for the notice on the transclusion or the talk page, expect it to be removed by someone else. When putting this on a page, you should also list the reason on that page's talk page, for any future readers that may want to know the purpose of the deletion.

{{delete|This is not a real thing.}}

Result:

distinguish

Template:Distinguish lets you notify users about pages that share similar names or may be confused for something else.

Example from Follow Freeman:

{{distinguish|"Follow Freeman!"|desc1=The HL2 chapter}}

Result:

Not to be confused with "Follow Freeman!" (The HL2 chapter).

ent

Template:Ent is a really small template for making text that's both code and a link.

{{ent|noclip}}

Result: noclip

Expand/ExpandBox

Template:Expand or Template:ExpandBox allows you to hide stuff inside a box that can be shrunk down so that it doesn't make pages as long.

{{Expand|{{KV BaseEntity|noscroll=1}}}}

Result: {| class="mw-collapsible mw-collapsed" style="background:rgba(0,0,0,0.05) ;float:no;margin-bottom:1em;margin-left:0;padding-right:0.5em;border:1px solid rgba(255,255,255,0.1); border-left:solid 1px #8bb9e0; padding-left:1em;" |+ style="text-align:left; white-space:nowrap; font-weight:bold; color:#ddd; " | | |}

{{ExpandBox|{{KV BaseEntity|noscroll=1}}}}

Result:


how

Template:How asks the question how?

Players can get past these.{{how}}

Result: Players can get past these.[How?]

idea

Template:Idea is a nifty way to suggest ideas.

{{idea|Reward players for being clever and creative, instead of forcing things to be only one way.}}

Result:

Tip.pngIdea:Reward players for being clever and creative, instead of forcing things to be only one way.

merge

Template:Merge is a notice that notifies editors that it's been suggested for two or more pages to be combined into one. All merges should be discussed before being done.

{{merge|HDR}}

Result:

messagebox

Template:Messagebox provides a standard message box. This template is used by many notice templates, such as merge and cleanup.

{{messagebox|text=Remember to follow wiki etiquette.}}

Result:

morescreenshots

Template:Morescreenshots marks pages that should have more images on them. It allows for an optional text message to clarify what needs images.

{{morescreenshots|$envmapcontrast, $envmapsaturation}}

Result:

note

Template:Note is for making notes stand out more.

Icon-Bug.pngBug:Appears to not accept HTML tags inside it...?  [todo tested in ?]
{{note|This will spawn at the map origin if you do not specify the position.}}

Result:

Note.pngNote:This will spawn at the map origin if you do not specify the position.

obsolete

Template:Obsolete marks things that should no longer be used. Accepts three parameters, entity, tool, and shader.

{{obsolete|entity=1}}

Result:

otherlang2

Template:Otherlang2 is used for linking to versions of pages in other languages. For an example of its use, see the Main Page.

Note.pngNote:It is preferrable to use Template:Lang instead, because it automatically recognizes every translation for a page, so long as the page name conforms to a standard naming scheme.

shortcut

Template:Shortcut displays a small box noting (abbreviated) redirects to a page.

{{shortcut|VDC:AL}}

Result:

Shortcut
VDC:AL

spammer

Template:Spammer marks users that should be banned for spamming.

Icon-Bug.pngBug:This template's formatting may look weird sometimes. It's intended to be the only thing on a page.  [todo tested in ?]
{{spammer}}

Result:

Spammer.jpg
Note.pngNote:This user is a spammer, vandal or other problem poster and should be considered for a ban

split-apart

Template:Split-apart marks pages that should be split into multiple pages. All splits should be discussed before being done.

{{split-apart}}

Result:


stub

Template:Stub marks pages that are very small. See Help:Stubs for info on using.

{{stub}}

Result:

tip

Template:Tip marks text as a tip to readers.

{{tip|This is a much less tricky process when using the vertex edit tool as well.}}

Result:

Tip.pngTip:This is a much less tricky process when using the vertex edit tool as well.

toc-right

Template:toc-right shifts the table of contents over to the right side of a page. For an example, see Half-Life 2 map reference.

todo

Template:Todo marks things that need to be done. It's green color is meant to stand out.

{{todo|Find where this is in the game files.}}

Result: To do: Find where this is in the game files.

unsigned

Template:Unsigned is for talk pages. It should be added at the ends of unsigned comments.

{{unsigned|JeffLane}}

Result: Unsigned comment added by JeffLane (talkcontribs) Always sign your posts with four tildes (~~~~)

update

Template:Update marks outdated pages.

{{update}}

Result:

warning

Template:Warning marks things that readers should take caution of when doing something.

{{warning|This tool has been known to corrupt files. Try an alternative listed below.}}

Result:

Warning.pngWarning:This tool has been known to corrupt files. Try an alternative listed below.

why

Template:Why asks the question why?

This shader has been deprecated.{{why}}

Result: This shader has been deprecated.[Why?]

wip

Template:Wip marks pages that are in the middle of major edits. The adder requests that other users do not edit in the meantime.

{{WIP|~~~}}

Result:

Magic words

Magic words are special character strings that are kind of like templates. To apply one, simply type it on the page.

__TOC__

Forces the table of contents to be placed at this spot.

__FORCETOC__

Forces the table of contents to be placed at its normal spot. (Only useful on pages that don't have enough sections to automatically display a TOC.)

__NOTOC__

Hides the table of contents.

__HIDDENCAT__

Marks a category as hidden. To make the website show hidden categories for you, check the Show hidden categories box in Special:Preferences.

{{DISPLAYTITLE:title}}

Changes the title of a page at the top bar only.

See Also