Difference between revisions of "Help:Editing/Templates"

From Frictional Wiki
Jump to navigation Jump to search
(→‎Useful templates: Added a confirm template)
 
(4 intermediate revisions by one other user not shown)
Line 100: 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}}
  
===Clarify===
+
===Confirm===
[[Template:Confirm]] marks things that should be confirmed.
+
[[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>This might require changing the distance parameter.{{confirm}}</pre>
 
<pre>This might require changing the distance parameter.{{confirm}}</pre>
 
Result: This might require changing the distance parameter.{{confirm}}
 
Result: This might require changing the distance parameter.{{confirm}}
Line 174: Line 174:
 
Result:
 
Result:
 
{{splitApart}}
 
{{splitApart}}
 
===TocRight===
 
[[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.
 
  
 
===Todo===
 
===Todo===
Line 182: Line 179:
 
<pre>{{todo|Find where this is in the game files.}}</pre>
 
<pre>{{todo|Find where this is in the game files.}}</pre>
 
Result: {{todo|Find where this is in the game files.}}
 
Result: {{todo|Find where this is in the game files.}}
 
===Ent===
 
[[Template:Ent]] is a really small template for making text that's both code and a link.
 
<pre>{{ent|mod}}</pre>
 
Result: {{ent|mod}}
 
  
 
===ExpandBox===
 
===ExpandBox===
Line 192: Line 184:
 
<pre>{{ExpandBox|{{:Help:Contents}}}}</pre>
 
<pre>{{ExpandBox|{{:Help:Contents}}}}</pre>
 
Result: {{ExpandBox|{{:Help:Contents}}}}
 
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===
 
===Clr===
Line 207: Line 204:
  
 
this bit of text here will get moved down.
 
this bit of text here will get moved down.
 +
 +
===TocRight===
 +
[[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>{{TocRight}}</pre>
  
 
==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