Skip to content

Like mustache, but thought out properly.

License

Notifications You must be signed in to change notification settings

ldgabbay/foostache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

foostache

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.

Quick example

Template

{{:iterate my_array 1::2}}{{. %5.2f}}{{:before}}[{{:between}}, {{:after}}]{{:end}}

Input

{ "my_array": [2.6, 4, 18, 3.51, 42, 96.8] }

Output

[ 4.00,  3.51, 96.80]

Philosophy

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:

  1. should be independent of platform and programming language
  2. should keep rendering logic entirely in the template
  3. 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:

  1. mustache is language dependent
  2. 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.

Resources

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.

About

Like mustache, but thought out properly.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages