Key Concepts

For those that are looking to dive straight into the code, there are only two simple key concepts that need to be understood, namely:

the parsing
The templar files (by convention having a '.templar' extension) are first parsed and tokenised.
the rendering
Once parsing has successfully completed, the parsed files are then rendered.

Background

Templar was designed with the following goals:

  • light-weight - only one dependency (and this is to allow JSON values for the context - and this is built in!)
  • whitespace is important - we (sometimes) care about newlines, spaces and tabs
  • easy to use
  • just powerful enough

When h2zero was in it's infancy, we needed a templating engine that would satisfy all of the above criteria - especially the whitespace - which we see as on of the most important ones (no one likes generated code that is ugly). So we search around and evaluated the following:

  • Velocity
  • FreeMarker
  • StringTemplate
  • JSPs !!!

All required huge libraries, lots of dependencies until we found the (now very much defunct) JavaTemplar engine from https://code.google.com/p/javatemplar/ (last updated July 2011). (although we do like their icon!).

Whilst this didn't quite have enough functionality to do what we required, it inspired us to build our own, which has now grown into a feature-rich templating engine.

In fact this site was generated with synapticloop templar-gen which utilises the library.

See the Quick Start to get up and running in no time at all, then check out theSyntax Reference and Function Reference for help.

Download

Download a release from GitHub and get started.