Help:Templates: Difference between revisions

Jump to navigation Jump to search
colourcoding for visual & source editors; small language changes
(rewrite, wip)
(colourcoding for visual & source editors; small language changes)
Line 12: Line 12:


=== Template call ===
=== Template call ===
The contents of a template can be added (or ''transcluded'') to a page using a ''template call''. A template call is an instruction for the system to search for that template and show its content on the ''target page'' when someone is reading it. As such, the template calls are similar to function calls in most programming languages.
The contents of a template can be added (or ''transcluded'') to a page using a ''template call''. A template call is an instruction for the system to search for that template and show its content on the ''target page'' when someone is reading it. As such, the template calls are similar to function calls in programming languages.


<div style="padding: 5px 10px 5px; border-left: 5px solid lightpink;">
In source editing, a template can be called using two curly brackets around the name of the template without the “Template:” prefix. For example, <code><nowiki>{{Mirror universe}}</nowiki></code> calls the [[Template:Mirror universe]]. It is a template used to inform the readers that the page covers a [[Mirror universe]] topic. Below is what it would look like:
In source editing, a template can be called using two curly brackets around the name of the template without the “Template:” prefix. For example, <code><nowiki>{{Mirror universe}}</nowiki></code> calls the [[Template:Mirror universe]]. It is a template used to inform the readers that the page covers a [[Mirror universe]] topic. Below is what it would look like:


{{Mirror universe}}
{{Mirror universe}}</div>


In the Visual Editor, you can add a template call to a page by opening the “Insert” menu from the toolbar and clicking “Template”. This will open a dialog box (popup) with a search bar for finding the template. After selecting a template, you may add the template to the page by clicking “Insert” in the top right corner of the dialog box.
<div style="padding: 5px 10px 5px; border-left: 5px solid lightgreen;">In the Visual Editor, you can add a template call to a page by opening the “Insert” menu from the toolbar and clicking “Template”. This will open a dialog box (popup) with a search bar for finding the template. After selecting a template, you may add the template to the page by clicking “Insert” in the top right corner of the dialog box.</div>


=== Parameters ===
=== Parameters ===


Templates can also take information the user gives them and change its appearance or functionality depending on the user’s input. For this purpose, the user would use ''parameters''. When calling a template, the user has an option to give a value to a parameter. The value given for a parameter can be text, files, code or even other templates.
Templates can also take information the user gives them and change its appearance or functionality depending on your input. For this purpose, you would use ''parameters''. When calling a template, you have an option to give a value to a parameter. The value given for a parameter can be text, files, code or even other templates.


In Visual Editor, the dialogue will ask values to each parameter separately. You can choose which parameters you want to use.
<div style="padding: 5px 10px 5px; border-left: 5px solid lightgreen;">
In Visual Editor, the dialogue will ask values to each parameter separately. You can choose which parameters you want to use.</div>


<div style="padding: 5px 10px 5px; border-left: 5px solid lightpink;">
In source editing, parameters are separated in the template call by | symbol (vertical bar). Parameters and what they do can typically be found on the template documentation page. There are two types of parameters, named and unnamed.
In source editing, parameters are separated in the template call by | symbol (vertical bar). Parameters and what they do can typically be found on the template documentation page. There are two types of parameters, named and unnamed.


Line 39: Line 42:


{{Quote box | quote = Tea, Earl Grey, hot | source = —Jean-Luc Picard | title = Example }}
{{Quote box | quote = Tea, Earl Grey, hot | source = —Jean-Luc Picard | title = Example }}
Instead of unnamed parameters, many templates have named parameters. They are also separated from the template name and each other with vertical bars. The parameter’s name is given, after which comes the equality sign =, and lastly the value given to the parameter.
Instead of unnamed parameters, many templates have named parameters. They are also separated from the template name and each other with vertical bars. The parameter’s name is given, followed by the equality sign =, and lastly the value given to the parameter.
For example, if you would want to show a quote someone said, you may use a [[Template:Quote box]] with a template call like <code><nowiki>{{Quote box | quote = Tea, Earl Grey, hot | source = —Jean-Luc Picard | title = Example }}</nowiki></code>, with the result on the right.
For example, if you would want to show a quote someone said, you may use a [[Template:Quote box]] with a template call like <code><nowiki>{{Quote box | quote = Tea, Earl Grey, hot | source = —Jean-Luc Picard | title = Example }}</nowiki></code>, with the result on the right.


Sometimes you might want to use unnamed parameters out of order. In that case, the ordinal of the unnamed parameter can be used as the parameter name, i.e. the first parameter has the name “1”. As such, the example with the ribbons also works with the code <code><nowiki>{{Ribbons|2=120|1=Innovation Ribbon|3=2}}</nowiki></code>.
Sometimes you might want to use unnamed parameters out of order. In that case, the ordinal of the unnamed parameter can be used as the parameter name, i.e. the first parameter has the name “1”. As such, the example with the ribbons also works with the code <code><nowiki>{{Ribbons|2=120|1=Innovation Ribbon|3=2}}</nowiki></code>.</div>


{{LCARS-bar-heading|Learn more|COLOR={{Color|blue}}}}
{{LCARS-bar-heading|Learn more|COLOR={{Color|blue}}}}
1,797

edits

Navigation menu