4.9 KiB
Template variables
Here is the full list of the available text template variables that you can customize in your wording file and the name of the variable parameters some of them expect.
Variables are prefixed by a $
and may be enclosed in brackets { }
to lift any ambiguity and separate the variable from the surrounding characters (exemple : does the template the $nth
refers to a nth
variable or is it the variable n
followed by the literal characters th
? the first interpretation prevails, and if you want the second one you should write the ${n}th
).
Most of the templates are used «at compile-time» when the blog is generated and so errors, missing variables etc. are caught early but some like metadata are only used client-side and hence need to be more resistant. If a variable present in a template is missing when the template is rendered, an undefined
JS value is returned.
Now some contexts, especially article contexts may vary a bit so some templates like metadata
need a way to «catch» those null values and keep up templating. For instance, an article may or may not have an author or tags. You could for instance decide that the base articles of your blog aren't signed because they obviously come from you or the organization that publish the blog but that when the blog publishes an article by a special guest it needs a special mention. To «harden» a template string against possible null values, just enclose the corresponding optional part between ${? ?}
.
allLink
The text used in the link to the full page on the latest page of the same category.
allPage
The <h2>
title used on the full page for all the articles.
allTaggedPage
The template for the <h2>
title used on the full pages for all the articles tagged a given tag.
It of course expects one variable named $tag
: the name of the tag for the given page.
commentsLink
The text displayed after the comments as a link to the toot that opens the comments section inviting visitors to comment the post.
commentsSection
The content of the <h2>
element at the begining of the comments on the pages of articles that have comments enabled.
dateFormat
This isn't really a template per-se but impacts the way the dates are generated to use in the metadata template. More precisely it contains the arguments passed to the toLocaleDateString method. It can thus only consist in a locale name, but since toLocaleDateString
also accepts an object as second argument, you can write the whole thing using JSON like this :
dateFormat = ["en-AU", {"month":"long", "day":"2-digit"}]
latestLink
The text used in the link to the latest page on the full page of the same category.
latestPage
The <h2>
title used on the latest page for all the articles. This page is the main page of your blog so this is more or less the first title that people see when they come to your blog.
latestTaggedPage
The template for the <h2>
title used on the latest pages for all the articles tagged a given tag.
It of course expects one variable named $tag
: the name of the tag for the given page.
metadata
The template of the text used to present the metadata associated to each article. This template is used both in the preview of an article on any page that lists it and on the article's page itself. It expects three possible variables
$author
$date
$tags
As mentioned in the introduction, some of them may be null so you may want to protect the whole metadata
template with ${? ?}
like it is done in this variable's default value :
metadata = ${?by ${author} ?}on ${date}${? tagged ${tags}?}
If an article has an author, the rendered metadata
string will start with «by », otherwise it will directly start with «on ». Likewise all articles with tags will have their metadata
end with « tagged » and then the list of comma-separated tags but if an article doesn't have tags, it will simply end after the date.
tagsList
The content of the <h2>
element in the navigation <div>
that lists all the tags of your blog.