0.6.0 • Published 11 years ago

richardparker v0.6.0

Weekly downloads
30
License
-
Repository
-
Last release
11 years ago

Richard Parker

Simple template engine for two way bindings.

Richard Parker

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.

Syntax

Its kind of Mustache in s-expressions.

Template:

{has .tigers
  <ul>
    {each .tigers
      <li x-bind="{path .name}">{.name}</li>
    }
  </ul>
}

Data:

{
  tigers: [
    {name: 'Richard Parker'}
    {name: 'Thirsty'}
  ]
}

Output:

<ul>
  <li x-bind=".tigers[0].title">Richard Parker</li>
  <li x-bind=".tigers[1].title">Thirsty</li>
</ul>

The possibility to output the current path is intended to be used for two way data bindings.

Installation

Using npm

$ npm install richardparker

Using Component

$ component install richardparker

Usage

The package can be consumed as a component or as a npm module. For use on the server and on the client.

Command-line

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

Javascript API:

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>}'),

Extensibility

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

0.6.0

11 years ago

0.5.0

11 years ago

0.4.0

11 years ago

0.3.1

11 years ago

0.2.0

11 years ago

0.1.0

11 years ago

0.0.1

11 years ago