A template parser that processes text in a specific format:
An optional vars section that looks like this:
var1: value var2: value var2 (condition): value --
Variable names may be repeated in the vars section.
Then, a series of a mixture of plain text blocks and modifiers. Modifiers
exist on a single line that begins and ends with [ and ]. They affect the
following text block only. Text blocks are all other text.
Modifiers can be joined on a single line by placing a semicolon between
them, e.g. [modifier 1; modifier 2]
This returns an object with two properties:
vars: a array of {name, condition, value} structures, where both condition and
value are functions. The condition evaluates to whether the value should be
set at all, and the value property evaluates to the value to set.
A template parser that processes text in a specific format:
Variable names may be repeated in the vars section.
[
and]
. They affect the following text block only. Text blocks are all other text.Modifiers can be joined on a single line by placing a semicolon between them, e.g.
[modifier 1; modifier 2]
This returns an object with two properties:
vars
: a array of{name, condition, value}
structures, where bothcondition
andvalue
are functions. Thecondition
evaluates to whether the value should be set at all, and thevalue
property evaluates to the value to set.