public
Description: Light-weight and simple templating engine for Ruby
Homepage:
Clone URL: git://github.com/manveru/ezamar.git
ezamar /
name age message
file AUTHORS Wed Jun 03 20:25:03 -0700 2009 Fix everything [manveru]
file CHANGELOG Wed Jun 03 20:25:03 -0700 2009 Fix everything [manveru]
file MANIFEST Wed Jun 03 20:25:03 -0700 2009 Fix everything [manveru]
file README Wed Jun 03 19:48:32 -0700 2009 Make it grow [manveru]
file README.md Mon Mar 09 06:43:46 -0700 2009 Extract Ezamar from Ramaze [manveru]
file Rakefile Wed Jun 03 20:25:03 -0700 2009 Fix everything [manveru]
file ezamar.gemspec Wed Jun 03 20:25:03 -0700 2009 Fix everything [manveru]
directory lib/ Wed Jun 03 19:49:32 -0700 2009 Version 2009.06 [manveru]
directory misc/ Mon Mar 09 06:43:46 -0700 2009 Extract Ezamar from Ramaze [manveru]
directory spec/ Wed Jun 03 19:48:32 -0700 2009 Make it grow [manveru]
directory tasks/ Wed Jun 03 20:25:03 -0700 2009 Fix everything [manveru]
README.md

Ezamar

Ezamar is a light-weight and simple templating engine for Ruby.

The first versions date back to 2006 when Ramaze was created, but I extracted it from Ramaze to level the playfield for more competitve engines.

It is based on a number of so-called pipes that perform evaluation and substitution on a String.

Features

  • Simple implementation
  • No dependencies
  • Elements for easy encapsulation of partial functionality
  • Template compilation
  • (X)HTML compatible

Dependencies

Ezamar should work with any Ruby implementation that conforms to MRI versions since 1.8.4 and possibly earlier versions as well.

Basic usage

require 'ezamar'

string = 'The Answer is #{21 + 21}'
template = Ezamar::Template.new(string, :file => '<eval>')
template.result(binding)

Syntax

Since Ezamar is based on Ruby String interpolation you can use any valid interpolation syntax inside your templates and it will be put into the result. There are 3 special instructions that will result in string substitutions during template compilation.

Evaluate without interpolation

<?r rubycode ?>

Evaluates the code inside the tag, this is considered XHTML-valid and so is the preferred method for executing code inside your templates. The return-value is ignored.

Evaluate with interpolation

#{ rubycode }

You know this from normal ruby already and it's actually nothing else. Interpolation at the position in the template, isn't any special taggy format and therefor safe to use.

Evaluate without interpolation (ERB style)

<% rubycode %>

The same as <?r ?>, ERB-style and not valid XHTML, but should give someone who is already familiar with ERB some common ground

Evaluate with interpolation

<%= rubycode %>

The result of this will be interpolated at the position in the template. Not valid XHTML either.

Thanks to

  • Jonathan Buch

    Who is of the first users of Ezamar, found a ton of bugs and provided the RenderPartial pipeline.

  • Zenix

    Who provided documentation.

  • The folks in #ramaze on irc.freenode.net

    Who kept pushing Ezamar to new limits and contributed a lot.

  • George Moschovitis a.k.a gmosx

    Who inspired the Ramaze project and Ezamar through his awesome work on the original Nitro framework.