Usage — Templates
The template is a HTML file with placeholders. Set up as you like it. Let gresiblos use your template using the --template <TEMPLATE_FILE> (or -t <TEMPLATE_FILE> for short) option where <TEMPLATE_FILE> is the path to your template.
The entry's meta data will be inserted into the file at places marked by [[:<FIELD_NAME>:]].
So given the entry:
state:release
title:My first blog entry
filename:my-first-blog-entry
author:John Doe
date:2025-01-02 19:25:00
topics:blog,example
abstract:A very first introduction into blogging
content:
<b>Hello there!</b><br/>
This is my very first blog post!
===
and the template:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>[[:title:]] — A sample blog</title>
</head>
<body>
<header>
<h1>[[:title:]]</h1>[[:?date:]]
<p class="date">Published on [[:date:]]</p>[[:date?:]]
</header>
<!-- Optional topics section -->
[[:?topics:]]<div class="topics">Topics: [[:topics:]]</div>[[:topics?:]]
<!-- Optional abstract section -->
[[:?abstract:]]<div class="abstract">[[:abstract:]]</div>[[:abstract?:]]
<!-- Main content -->
<article>
[[:content:]]
</article>
<div id="footer">© Copyright [[:author2|John Doe:]]</div>
</body>
</html>
you will get
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>My first blog entry — A sample blog</title>
</head>
<body>
<header>
<h1>My first blog entry</h1>
<p class="date">Published on <DATE1></p>
</header>
<!-- Optional topics section -->
<div class="topics">Topics: blog, example</div>
<!-- Optional abstract section -->
<div class="abstract">A very first introduction into blogging</div>
<!-- Main content -->
<article>
<b>Hello there!</b><br/>
This is my very first blog post!
</article>
<div id="footer">© Copyright John Doe</div>
</body>
</html>
Default values
Replacements defined using [[:<FIELD_NAME>:]] with no value in their meta data for <FIELD_NAME> will be replaced by an empty string (will be removed). In the example above, [[:includes:]] is such a case.
You though may define defaults for the values using the format [[:<FIELD_NAME>|<DEFAULT>:]]. In this case, this part will be replaced by the value from the blog entry data if the meta data <FIELD_NAME> is set. Otherwise, <DEFAULT> will be inserted. In the example above, [[:author2|John Doe:]] is such a case, as author2 is not given in the meta data.
Optional parts
In some cases, it is not sufficient to use defaults. If, e.g., no topics are given, it would not make sense to have a default:
...
<div class="topics">Topics: </div>
...
gresiblos allows to tag parts of the document if a certain meta data is not given. The begin of the optional document part is marked using [[:?<FIELD_NAME>:]], the end using [[:<FIELD_NAME>?:]]. The contents between those markers are removed if <FIELD_NAME> is not given in the meta information. So
...
<!-- Optional topics section -->
[[:?topics:]]<div class="topics">Topics: [[:topics:]]</div>[[:topics?:]]
<!-- Optional abstract section -->
[[:?abstract:]]<div class="abstract">[[:abstract:]]</div>[[:abstract?:]]
...
will — in the case topics is not given within the meta information — become
...
<!-- Optional topics section -->
<!-- Optional abstract section -->
[[:?abstract:]]<div class="abstract">[[:abstract:]]</div>[[:abstract?:]]
...
This means that the part enclosed in [[:?topics:]] and [[:topics?:]] is removed if the meta information topics is not defined.