Simple template engine for two way bindings

Richard Parker

Simple template engine for two way bindings.

A Tiger? Richard Parker was a Tiger? Yeah! He got his name through a clerical error. A Hunter caught him when drinking from a stream when he was a cub, and named him Thirsty. When Thirsty got too big, the hunter sold him to our zoo, but the names got switched on the paperwork. The hunter was listed as Thirsty and the tiger was called Richard Parker. We laughed about it and the name stuck.

Render some tigers with Richard Parker

Its kind of Mustache in s-expressions.


{has fields
    {each fields
      {. label}: <input type="text" x-bind="{path name}" value="{. name}">


  fields: [
    {label: 'Hunter', name: 'Thirsty'},
    {label: 'Tiger', name: 'Richard Parker'}


  Hunter: <input type="text" x-bind="" value="Thirsty">
  Tiger: <input type="text" x-bind="" value="Richard Parker">

In the example above the x-bind attribute is set to the path of the names in the data object. This is intended to be used for two way data bindings.

Richard Parker has no built in data bindings, but the bindings can be done with Pflock which uses the same syntax as the {path} macro.

Using npm

$ npm install richardparker

Using Component

$ component install manuelstofer/richardparker

The package can be consumed as a component or as a npm module.

Richard Parker can compile templates to common js or optionally to amd modules.

$ richardparker template.html       # compile template.html and output to stdout
$ richardparker -a foo.html         # compile test.html and output as amd module
var richard = require('richardparker'),
    // render directly
    html = richard('{has title <h1>{. title}</h1>}', {name: 'foo'});
    // compile to javascript function
    template = richard.compile('{has title <h1>{. title}</h1>}'),

New commands can be added quite easily as compile time marcros. To see how its done checkout the native marcros like has, each and path.