The templatery plugin offers the ability to write a template, and have it included in other pages with filled in fields.
Defining a template is very simple:
<template example>
This starts a new template. The template can optionally have a name ('example' in this case).
Hello, my name is: @@name@@
A piece of text with a field called 'name'.
<if organisation> I'm a member of @@organisation@@. </if>
A conditional piece of text. If the field 'organisation' is present, this will be displayed. If the field is not defined, the whole piece won't be used.
</template>
Finishes the template.
The template will end up looking like this:
Hello, my name is: Name
I'm a member of Organisation.
You use the template with
{{template>wiki:templatery#example|name=Brend|organisation=University of Twente}}
This tells the wiki to use the template wiki:templatery#example.
If you do not have a full name, but something like {{template>test}} the wiki will look in the template namespace for the template.
Looks like this
Hello, my name is: Brend
I'm a member of University of Twente.
A template can have both named and numbered parameters.
Parameters can be numbered:
0 = 0, 1 = 1
0 = Alpha , 1 = beta
You can freely mix numbered and named parameters.
Parameters can be numbered:
a » Default value for a & B » Default value for b
Alpha & Default value for b
You can have conditional pieces of template:
Text if a is set. a = a
Text if a is not set. a = A
With A set
Text if a is set. a = Alpha
With A unset
Text if a is not set. a =
Conditionals will be block-level if possible and will switch to inline if necessary.
This is useful, for example, if you have them in a list item.
You can force a conditional to be inline by prefixing it with a *
.
Some With BB value of B.
Some tomato value of B.
You can include a template in a template. This allows you to reuse templates.
If you dot this, you use {{template>name of template|inside=outside}}. The variables assignments are used to remap variables from outside the template to inside the template. Any variable not mentioned is available under it's old name.
0 = Alpha
0 = Beta
0 = Gamma
0 = Delta