Templates
Templates allow us to make pages with regular, reusable parts, render special, dynamic content, or mark pages with particular data structures.
#Format
Using a template on a page usually involves a string of text wrapped in a pair of curly brackets, like so:
{{TemplateName}}
Templates can have parameters, too, written like this:
{{TemplateName parameter1="v1" parameter2="v2"}}
If you add this to a page, rather than rendering the string as you wrote it, the Fifth World API will look for a template called TemplateName
. If the template exists, the API will render it (using v1
for parameter1
and v2
for parameter2
), and replace the string with the result of that rendering. If it doesn’t exist, the API will simply remove the string from the rendered page.
#Data templates
Since we simply remove the text if no template matches the invocation, we can use data templates to save information about a page, and then use the API’s GET /templates
endpoint to retrieve pages like that, or the special ListPagesUsingTemplate
template (see below) to render a list of them. If we decide later that we would like to render this data in some way, we can always add a template to do so.
For an example of this, see our entry on berries, which uses the Focus
template, along with parameters that specify that people gather berries in summer, and that both villages and bands sometimes dedicate themselves to gathering berries then. The community creation tool uses then uses this data to add berries to the list of foods that a community might focus on in the summer.
#System templates
The API has a small handful of built-in templates. These templates require some processing in the API to properly render, so you can’t create a template with any of these names, because then the renderer would have no way of distinguishing between your template and the built-in one.
#Art
This template allows you to render any art uploaded to the site as an image on a page.
Parameter | Notes |
---|---|
src | The path of the page for the art you want to use. |
numbered | If used (with any value), renders the art in a numbered figure (e.g., “Figure 1”). |
caption | Use this paramter to supply a caption for the art. |
useThumbnail | If used (with any value), renders the thumbnail rather than the full image. |
#Artists
This template finds all of the artists on the site (pages tagged with type “Artist”), lists them, and provides a small gallery of their four most recent works. We use it on the Art page.
#Children
This template creates a list of the page’s child pages (or another page’s children).
Parameter | Notes |
---|---|
of | Use this parameter to supply the path of a different page, to show that page’s children instead of the current page’s children. |
type | Use this parameter to limit the list to only children of the given type. |
order | Use this paramter to specify the order in which the renderer should list the children. You can choose between newest , oldest , and alphabetical . If you don’t supply this parameter, it defaults to alphabetical order (by title). |
#Gallery
This template renders a gallery of all of the art pages saved as children of a given root. We use this on artists’ pages (e.g., Dani Kaulakis), where the artist’s page servers as the root, allowing us to render a gallery of the artist’s work.
Parameter | Notes |
---|---|
of | Use this parameter to supply the path of a root other than the current page. |
#ListPages
This template renders a list of pages, fetched by criteria specified by the parameters.
Parameter | Notes |
---|---|
path | Use this parameter to supply a path to search for. This will match any page with the path, or that begins with the path (under most circumstances, this should mean a page and all of its descendants). |
title | Use this parameter to supply a title to search for. This will match any page that includes this string in its title. So, for example, “Anim” will match both Animism and Animal. |
type | Use this parameter to match pages of the given type. |
tags | Use this parameter to match pages that have the given tags. You can search for pages that simply have the tag (tag ), or only those pages that have the tag and have set it to a particular value (tag:value ). You can string together multiple criteria with semicolons (tag1;tag2:value;tag3 ). |
logic | Use this parameter to specify how to treat your search criteria. By default, the parameter uses and logic, meaning that it will only list pages that match all of the criteria provided, but you can set this parameter to or , in which case it will list those pages that match any of the criteria provided. |
limit | Use this parameter to set a maximum on the number of pages listed. This defaults to 10. |
#ListPagesUsingTemplate
This template renders a list of pages that use a particular template. You can use its parameters to limit that to those pages that use a particular template and also provide a particular parameter, or further, only those that set that parameter to a particular value.
Parameter | Notes |
---|---|
template | Use this parameter to specify a template. It will render a list of pages that use this template. |
parameter | If you supply this parameter, the API will limit the list of pages to those that use the template and the given parameter. |
value | If you supply both this and parameter , the API will limit the list of pages to those that (a) use the template specified by template , (b) and supply the parameter specified by parameter , and (c) set that parameter to the value specified by value . |
#Novels
This template renders a list of novels with their covers. You can see it in use on the Stories page.
#RequestedLinks
This template renders a table of requested links. You can see it in use on the Requested Pages page.
Parameter | Notes |
---|---|
num | Set the maximum number of rows to render (defaults to 25). |
#Tagged
This template renders a list of pages that use a particular tag, set to a particular value.
Parameter | Notes |
---|---|
tag | Use this parameter to specif the name of the tag you want to use. |
value | Use this parameter to specify the value of the tag you want to use. |
#Member-created templates
While our system templates provide some special functionality that call for some extra documentation, most of the utility of our templating system come from the templates that our members create. These exist within the website just like any other page. If you have an idea for a template, give it a shot! You can take a look at how other members created these templates for inspiration, or reach out on our Discord server for help.
- Disclaimer: Not Medical Advice
- E-Prime Warning
- Main
- PanelLink
- RPGAgendaHunt
- RPGAgendaMeet
- RPGAgendaSee
- RPGCorePrinciple
- RPGCorePrincipleAsk
- RPGCorePrincipleCare
Note: If you check the source for this page, you’ll see that we create the list above by using the ListPages system template, providing another example of how you can use templates like this.