foostache is a domain-specific language for specifying a template that can be used to generate unicode from JSON inputs.
Jump to the complete foostache specification.
{{:iterate my_array 1::2}}{{. %5.2f}}{{:before}}[{{:between}}, {{:after}}]{{:end}}
{ "my_array": [2.6, 4, 18, 3.51, 42, 96.8] }
[ 4.00, 3.51, 96.80]
There are many open source template languages to choose from, so why did I design a new one? Unfortunately, none of the existing ones matched the rigorous design philosophy I needed to uphold. A template language:
- should be independent of platform and programming language
- should keep rendering logic entirely in the template
- should be agnostic to the nature and syntax of the output
Why not mustache?
mustache users can call custom code by way of attaching functions to the input object. This means the input is not JSON but actually a JavaScript object, which means:
- mustache is language dependent
- logic may be split between the template and the input
Also, mustache assumes the output is HTML and escapes all fields as HTML by default. No other escaping filters, such as URI encoding or JavaScript string encoding, are supported. These would have to be done by custom code, which again makes the templating language language dependent.
This project is a specification only.
An ANTLR4 grammar for foostache can be found here.
A reference implementation in python is being maintained and can be found here.