Copyright | (c) 2024 Sena |
---|---|
License | GPL-3.0-or-later |
Maintainer | contact@sena.pink |
Stability | stable |
Portability | portable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Gemoire.Template
Contents
Description
A minimal template parser to use with generated static gemlogs
Gemoire uses its own template system, where the templates are plain texts with special inline components. The valid components are:
{$pholder$}
- A placeholder with the keypholder
{$pholder:default value$}
- A placeholder with a default value{&pholder:fallback&}
- With a fallback key to use in casepholder
has no value{&pholder:fallback:default value&}
- With a fallback key and a default value{# comment! #}
- An unrendered comment{\ constant \}
- An unevaluated block, akin to escaping things inside it
All inline components can be multiline in any way, including placeholder keys. The arguments can also be surrounded by any amount of whitespace, which will get stripped except when specifying a default value.
The surrounding braces are parsed in order, so the components can not be nested.
Formatting
Types
type Template = [Either Text Component] Source #
A basic template, in the form of a string of either plain text blocks or meaningful components
A parsed template component with a special meaning
Constructors
Placeholder !Text !(Maybe Text) | A placeholder with an optional default value |
Fallback !Text !Text !(Maybe Text) | A placeholder with another key to fallback to if the first one has no value, and an optional default value |