Combining templates and data is a good way to display a lot of data while still keeping it readable.
First we need a template:
Knows: knows
See the Templatery manual for more information on templates.
Second, we need some data:
Alice (example_person) | |
---|---|
Name | Alice the First |
Knows_ref | #Bob, #Donna |
Bob (example_person) | |
---|---|
Name | Bob the Builder |
Knows_ref | #Alice |
Carol (example_person) | |
---|---|
Name | Carol the Third |
Knows_ref | #Donna, #Alice |
Declaring data is done as described by Entering Data.
By giving a template in data entry, you can format an entry as well:
<data example_person #Donna> template { wiki:stratatemplatery } Name: Donna the Doer Knows_ref*: #Alice, #Carol </data>
Knows:
Note: By prefixing a class with !
, you can get a quick template on the data entry. Though this relies on being able to get the template from the template: namespace, and you can't use a #name
style template. For example:
<data !example_person #Donna> Name: Donna the Doer Knows_ref*: #Alice, #Carol </data>
This example would use the template:example_person template.
Now we can combine the data and the template:
<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 Asking Questions, with the addition of the template
group.
The result:
Knows: #Bob, #Donna
Knows: #Alice
Knows: #Alice, #Donna
Knows: #Alice, #Carol
Lists can be template as well. This offers the option of displaying a list with customized items for each result.
<listview ?name ?knows> ?p is a: example_person ?p entry title: ?name ?p Knows_ref: ?knows group { ?p ?name } <view> **@@name@@** -> @@knows@@ </listview>
The example code will result in:
<listview ?name ?knows> ?p is a: example_person ?p entry title: ?name ?p Knows_ref: ?knows
group {
?p ?name
} <view> name → knows </listview>
You can use types and aggregations in fields in the template. For example rating@max_stars will determine the maximum value of the 'rating' field in the query, and display this with the 'stars' 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 ^_^ + 7 8-)
and b=playground:playground
this gives the following:
An example: With explicit type: