Difference between revisions of "Help:Editing/Templates"

From Frictional Wiki
Jump to navigation Jump to search
 
(11 intermediate revisions by 2 users not shown)
Line 13: Line 13:
 
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]]:}}
+
{{note|Any page can be transcluded by another one actually. See more at ExpandBox}}
{{ExpandBox|{{: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.
Line 87: Line 85:
 
All templates in '''{{style|color:#8BC53F|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]].
 
All templates in '''{{style|color:#8BC53F|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]].
  
===Bug===
+
===How===
[[Template:Bug]] notifies readers of a [[Wikipedia:Software bug|bug]].
+
[[Template:How]] asks the question ''how?''
<pre>{{bug|The amount is double what it should be. Be careful!}}</pre>
+
<pre>Players can get past these.{{how}}</pre>
Result: {{bug|The amount is double what it should be. Be careful!}}
+
Result: Players can get past these.{{how}}
 +
 
 +
===Why===
 +
[[Template:Why]] asks the question ''why?''
 +
<pre>This shader has been deprecated.{{why}}</pre>
 +
Result: This shader has been deprecated.{{why}}
  
 
===Clarify===
 
===Clarify===
Line 97: Line 100:
 
Result: A user module can be created following the usual class creation procedure.{{clarify}}
 
Result: A user module can be created following the usual class creation procedure.{{clarify}}
  
===Cleanup===
+
===Confirm===
[[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:Confirm]] marks things that should be confirmed. This is mostly for when a statement can't be ruled out as false and contains potentially useful information.
<pre>{{cleanup|The last section needs to be clarified.}}</pre>
+
<pre>This might require changing the distance parameter.{{confirm}}</pre>
Result: {{cleanup|The last section needs to be clarified.}}
+
Result: This might require changing the distance parameter.{{confirm}}
  
===Clr===
+
===Required Version===
[[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:ReqVer]] is for noting a version required to do something.
 +
<pre>{{ReqVer|1.3}}</pre>
 +
Result: {{ReqVer|1.3}}
  
[[File:apple.png|50px|frameless|left]]
+
===Note===
 +
[[Template:Note]] is for making notes stand out more.
 +
<pre>{{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.}}
  
This text should appear next to the image. If you put <code><nowiki>{{clr}}</nowiki></code> right after this,
+
===Idea===
 +
[[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>
 +
Result: {{idea|Reward players for being clever and creative, instead of forcing things to be only one way.}}
  
this bit of text here will get moved down.
+
===Tip===
----
+
[[Template:Tip]] marks text as a tip to readers.
[[File:apple.png|50px|frameless|left]]
+
<pre>{{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.}}
  
This text should appear next to the image. If you put <code><nowiki>{{clr}}</nowiki></code> right after this,{{clr}}
+
===Warning===
 
+
[[Template:Warning]] marks things that readers should take caution of when doing something.
this bit of text here will get moved down.
+
<pre>{{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.}}
  
 
===Delete===
 
===Delete===
Line 122: Line 135:
 
Result: {{delete|This is not a real thing.}}
 
Result: {{delete|This is not a real thing.}}
  
===Ent===
+
===Stub===
[[Template:Ent]] is a really small template for making text that's both code and a link.
+
[[Template:Stub]] marks pages that are very small. See [[Help:Stubs]] for info on using.
<pre>{{ent|mod}}</pre>
+
<pre>{{stub}}</pre>
Result: {{ent|mod}}
+
Result: {{stub}}
  
===ExpandBox===
+
===Wip===
[[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:Wip]] marks pages that are in the middle of major edits. The adder requests that other users do not edit in the meantime.
<pre>{{ExpandBox|{{:Help:Contents}}}}</pre>
+
<pre>{{Wip}}</pre>
Result: {{ExpandBox|{{:Help:Contents}}}}
+
Result:
 +
{{Wip}}
 +
 
 +
===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.
 +
<pre>{{cleanup|The last section needs to be clarified.}}</pre>
 +
Result: {{cleanup|The last section needs to be clarified.}}
  
===How===
+
===MessageBox===
[[Template:How]] asks the question ''how?''
+
[[Template:MessageBox]] provides a standard message box. This template is used by many notice templates, such as merge and cleanup.
<pre>Players can get past these.{{how}}</pre>
+
<pre>{{messageBox|text=Remember to follow wiki etiquette.}}</pre>
Result: Players can get past these.{{how}}
+
Result: {{messageBox|text=Remember to follow wiki etiquette.}}
  
===Idea===
+
===Bug===
[[Template:Idea]] is a nifty way to suggest ideas.
+
[[Template:Bug]] notifies readers of a [[Wikipedia:Software bug|bug]].
<pre>{{idea|Reward players for being clever and creative, instead of forcing things to be only one way.}}</pre>
+
<pre>{{bug|The amount is double what it should be. Be careful!}}</pre>
Result: {{idea|Reward players for being clever and creative, instead of forcing things to be only one way.}}
+
Result: {{bug|The amount is double what it should be. Be careful!}}
  
 
===Merge===
 
===Merge===
Line 147: Line 166:
 
Result: {{merge|HDR}}
 
Result: {{merge|HDR}}
  
===MessageBox===
+
There's also a variant which allows linking to other namespaces: [[Template:Merge2]]
[[Template:MessageBox]] provides a standard message box. This template is used by many notice templates, such as merge and cleanup.
+
<pre>{{merge2|HDR}}</pre>
<pre>{{messageBox|text=Remember to follow wiki etiquette.}}</pre>
 
Result: {{messageBox|text=Remember to follow wiki etiquette.}}
 
  
===Note===
+
===SplitApart===
[[Template:Note]] is for making notes stand out more.
 
<pre>{{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.}}
 
 
 
===split-apart===
 
 
[[Template:SplitApart]] marks pages that should be split into multiple pages. All splits should be discussed before being done.
 
[[Template:SplitApart]] marks pages that should be split into multiple pages. All splits should be discussed before being done.
 
<pre>{{splitApart}}</pre>
 
<pre>{{splitApart}}</pre>
 
Result:
 
Result:
 
{{splitApart}}
 
{{splitApart}}
 
===Stub===
 
[[Template:Stub]] marks pages that are very small. See [[Help:Stubs]] for info on using.
 
<pre>{{stub}}</pre>
 
Result: {{stub}}
 
 
===Tip===
 
[[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>
 
Result: {{tip|This is a much less tricky process when using the vertex edit tool as well.}}
 
 
===TocRight===
 
[[Template:TocRight]] shifts the [[Help:Table of Contents|table of contents]] over to the right side of a page.
 
  
 
===Todo===
 
===Todo===
Line 181: Line 180:
 
Result: {{todo|Find where this is in the game files.}}
 
Result: {{todo|Find where this is in the game files.}}
  
===Warning===
+
===ExpandBox===
[[Template:Warning]] marks things that readers should take caution of when doing something.
+
[[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>{{warning|This tool has been known to corrupt files. Try an alternative listed below.}}</pre>
+
<pre>{{ExpandBox|{{:Help:Contents}}}}</pre>
Result: {{warning|This tool has been known to corrupt files. Try an alternative listed below.}}
+
Result: {{ExpandBox|{{:Help:Contents}}}}
 +
 
 +
===Quote===
 +
[[Template:Quote]] will format a sentence and put an author under its right side.
 +
<pre>{{Quote|That taste... that fragrance...|Daniel}}</pre>
 +
Result:{{Quote|That taste... that fragrance...|Daniel}}
 +
 
 +
===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.
 +
 
 +
[[File:apple.png|50px|frameless|left]]
 +
 
 +
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.
 +
----
 +
[[File:apple.png|50px|frameless|left]]
 +
 
 +
This text should appear next to the image. If you put <code><nowiki>{{clr}}</nowiki></code> right after this,{{clr}}
  
===Why===
+
this bit of text here will get moved down.
[[Template:Why]] asks the question ''why?''
 
<pre>This shader has been deprecated.{{why}}</pre>
 
Result: This shader has been deprecated.{{why}}
 
  
===Wip===
+
===TocRight===
[[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:TocRight]] shifts the [[Help:Table of Contents|table of contents]] over to the right side of a page. This page, for example, uses this template.
<pre>{{Wip}}</pre>
+
<pre>{{TocRight}}</pre>
Result:
 
{{Wip}}
 
  
 
==Magic Words==
 
==Magic Words==

Latest revision as of 11:50, 16 August 2020

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.

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 icon.png Any page can be transcluded by another one actually. See more at ExpandBox

Examples

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

{{example}}

Result: Template:Example

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

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:

{{DeleteMeta|{{#if: This is a bad page. | This is a bad page. }} }}[[Category:Candidates for 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:Example is rather easy - just type the text you want, and save it. What about ones with parameters?

Icon tip.png Tip: 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:

Icon tip.png Tip: Do not carve without vertex editing afterward.

If you want to add more than one unnamed parameter, simply add another number, increased by 1. For example:

SomeTemplate:{{{1}}} and {{{2}}}

Named Parameters

Usually you would want to have named parameters affect anything only if they are defined when being transcluded. Conditions will be discussed later. For now, let's look at Template:MessageBox, which has some named parameters. In this template, {{{text}}} marks a place to add wikitext that's defined by |text = Text here when transcluding.

With named parameter:

{{MessageBox|text=my text}}

Result:


Without named parameter:

{{MessageBox}}

Result:


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.

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.

noinclude keeps wikitext inside it from appearing on the destination page, while keeping it on the source page.

onlyinclude makes only wikitext inside it appear on destination pages. Text not inside these will still appear on the template's page.

includeonly 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.

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.

How

Template:How asks the question how?

Players can get past these.{{how}}

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

Why

Template:Why asks the question why?

This shader has been deprecated.{{why}}

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

Clarify

Template:Clarify marks things that should be clarified.

A user module can be created following the usual class creation procedure.{{clarify}}

Result: A user module can be created following the usual class creation procedure.[Clarify]

Confirm

Template:Confirm marks things that should be confirmed. This is mostly for when a statement can't be ruled out as false and contains potentially useful information.

This might require changing the distance parameter.{{confirm}}

Result: This might require changing the distance parameter.[Confirm]

Required Version

Template:ReqVer is for noting a version required to do something.

{{ReqVer|1.3}}

Result: Alert icon.png Requires version 1.3

Note

Template:Note is for making notes stand out more.

{{note|This will spawn at the map origin if you do not specify the position.}}

Result:

Note icon.png This will spawn at the map origin if you do not specify the position.

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:

Icon idea.png Idea: Reward players for being clever and creative, instead of forcing things to be only one way.

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:

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

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:

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

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:

Stub

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

{{stub}}

Result:

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:

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:


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:


Bug

Template:Bug notifies readers of a bug.

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

Result:


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:

There's also a variant which allows linking to other namespaces: Template:Merge2

{{merge2|HDR}}

SplitApart

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

{{splitApart}}

Result:

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.

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.

{{ExpandBox|{{:Help:Contents}}}}

Result:

Quote

Template:Quote will format a sentence and put an author under its right side.

{{Quote|That taste... that fragrance...|Daniel}}

Result:

"That taste... that fragrance..."
Daniel

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.

Apple.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.


Apple.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.

TocRight

Template:TocRight shifts the table of contents over to the right side of a page. This page, for example, uses this template.

{{TocRight}}

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