cppt
Write templates in C preprocessor language.
Example
./cppt -D'TITLE="cppt_demo_#1"' -D'USERS(u)=u("Jesus",2015)u("Alice",17)u("Max",-1)' <example/example.cppt
The output is a chunk of HTML:
cppt_demo_#1Users:Jesus2015Alice17Max-1
And here is what the template itself looks like:
Preprocessor templates
Cppt template files must #define
the html
symbol as a string - the result of applying the template.
A few primitives are built in.
t(tag, attributes, content)
Creates a tag with given attributes and content.
t1(tag, attributes)
Creates a void (a.k.a. self-closing) tag with no content.
a(key, value)
Creates an attribute. Can be combined with other attributes to form the attributes
string containing all of them.
CLI
Usage: cppt [-D<definition>]... <TEMPLATE
Definitions have to be in exactly the same format as described in GCC(1).
Note: to pass a sequence of objects, you create a definition that accepts another macro, applies it to each object in a sequence and then concatenates the results. See the example.
Dependencies
- GCC
License
MIT