blogc-template(7) -- blogc's template format ============================================ ## DESCRIPTION Template files are used as base to build output files by blogc(1). These files can include variables, blocks and conditionals, that will directly affect the output files. The syntax of the template files is defined to be simple, without affecting the content output. The syntax is somewhat inspired by Jinja2 syntax. This manual describes the basic syntax and functionalities of template files. ## TEMPLATE BLOCKS Template blocks are used to delimit content. The content inside a block will be included in the output file (or not) if the parameters passed to blogc(1) matches the requirements of the given block. Blocks can be defined more than once, but can't be nested. The available blocks are: `entry`, `listing` and `listing_once`. ### entry block The content of an `entry` block is included in the output file when blogc(1) is called without `-l` option, and with only one source file. It is used to render a single entry of your blog/website. All the variables defined in the source file are available inside this block (see blogc-source(7)), and will override global variables (see blogc(1)). This is how an `entry` block is defined: {% block entry %} This content will only be included when rendering a single entry. {% endblock %} ### listing block The content of a `listing` block is included in the output file when blogc(1) is called with `-l` option, and with one or more source files. It is used to create a listing of entries, and its content will be included once for each given source file (in the order that the source files were provided to blogc(1)). All the variables defined in the source files are available inside this block (see blogc-source(7)), and will override global variables (see blogc(1)). The variables will be provided by each file, when blogc(1) iterates over them. This is how a `listing` block is defined: {% block listing %} This content will be only included when rendering an entry listing, and will be included once for each entry. {% endblock %} ### listing_once block The content of a `listing_once` block is included in the output file when blogc(1) is called with `-l` option, and with one or more source files. It is like a `listing` block, but is only called once, and does not have access to the local variables defined in the source files. It is useful to add something before an entry listing. This is how a `listing_once` block is defined: {% block listing_once %} This content will be only included when rendering an entry listing, but will be included only once. {% endblock %} This is a 'real life' usage example of a `listing_once` block, supposing that each source file defines a `TITLE` variable: {% block listing_once %}