Vintage Story Wiki:Infobox tutorial: Difference between revisions

From Vintage Story Wiki
actually wrote a tutorial
(todo)
 
(actually wrote a tutorial)
Line 1: Line 1:
Using infoboxes can be daunting. This tutorial should give you a bit of a feel for them and help you work on the wiki!
Using infoboxes can be daunting. This tutorial should give you a bit of a feel for them and help you work on the wiki!
== Syntax ==
Infoboxes, and all templates actually, have similar syntax.
<pre>
{{TemplateName
|Param1=value
|Param2=value
...
}}
</pre>
In this example, the name is <code>TemplateName</code>. When inserting, formally "transcluding", a template into a page you will change this name. The parameters <code>Param1</code> and <code>Param2</code> are ''named parameters''. This means that they are referenced by name. Other parameters can be ''unnamed'' or ''anonymous parameters'' meaning they are not referred to by name. When transcluding the template it would look like this...
<pre>
{{TemplateWithAnonParams
|value
}}
</pre>
Some templates may utilize more than one anon parameter, in which case, you must be aware of the order of the values. When using named parameters, order ''does not matter'' however anon parameters must be in the correct order. When using a template that has both named and anon parameters, the anon parameters must be in the expected order, but named parameters do not have to be. Thus, in the following three examples, the first two are equivalent to each other but the third is not.
<pre>
{{BothAnonAndNamedParams
|Param=value1
|value2
|value3
}}
{{BothAnonAndNamedParams
|value2
|value3
|Param=value1
}}
{{BothAnonAndNamedParams
|value3
|value2
|Param=value1
}}
</pre>
== Documentation ==
Most templates ''should'' have a documentation table with them. A table will list the names of all parameters, whether they are required or optional and if there is a default value, and an example value.
{| class="wikitable"
|-
! Parameter !! Required or Optional, default if applicable !! Example
|-
| ''Name'' || Required || Dirt
|-
| ''Stackable'' || Optional, 64 || 64
|-
| ''Material'' || Optional || Soil
|}
This shows the template has 3 parameters, <code>Name</code>, <code>Stackable</code>, and <code>Material</code>. <code>Name</code> is required; it must be defined for the template to be correct. When a require parameter isn't specified, not defined, it will appear as <nowiki>{{{Name}}}</nowiki> on the page. <code>Stackable</code> is optional; it may or may not be defined. If there is a second value after "Optional" that is the default value. <code>Stackable</code> defaults to 64. <code>Material</code> is optional but does not have a default value.
Confirmedusers, Bureaucrats, editor, Administrators
1,522

edits