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>tech:templates#example|name=Brend|organisation=University of Twente}}
This tells the wiki to use the template tech:templates#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 given a default value:
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 =
You can use inline conditionals for inclusion in places where normal conditionals don't work (such as in lists, tables, etc.) The system will try to determine when to use an inline conditional by itself. You can force an inline conditional with *.
Forced inlines conditionals can be used With ainside of paragraphs!
With A
Forced inlines conditionals can be used inside of paragraphs!
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
Combining templates and data is a good way to display a lot of data while still keeping it readable.
We can combine the data and the template with a 'view':
<view ?name ?knows>
template {
manuals:stratatemplatery
}
?p is a: example_person
?p entry title: ?name
?p Knows [ref]: ?knows
group {
?p
?name
}
</view>
The <view> works exactly like Strata: Structured Data Plugin, with the addition of the template group.
You can use types and aggregations in fields in the template. For example rating@max [dot] will determine the maximum value of the 'rating' field in the query, and display this with the 'dot' type.
You can use types in vanilla templates as well. This allows you to display nicer templates without extra effort.
An example: a With explicit type: b [ref]
When filled in with a[wiki]=5 (:food) + 7 (:healthcare) and b=ic:Nehket Aeka this gives the following:
An example: 5
+ 7
With explicit type: Nehket Aeka