Walrus
Walrus is a free (open source) Object-Oriented templating engine written in Ruby. Plain text templates are compiled down to Ruby code; final output is produced by executing ("filling") the compiled templates.
Standard object-oriented patterns can be used to maximize re-use and minimize repetition, and custom behavior such as targeting multiple output formats from a single source template can be added using custom Ruby methods.
A walrus
command line tool is included
to make compiling and filling templates easy.
Walrus was inspired by the Cheetah template engine written in Python.
System requirements
Walrus currently only supports Ruby 1.8, although Ruby 1.9
compatibility work is underway. JRuby is not yet officially
supported, but some operations (notably batch compilation of
large numbers of files using
jruby -S walrus compile ...
) have been successfully
tested.
Installation
$ sudo gem install walrus
Further reading
Walrus was originally written an 2007 and as it was my first non-trivial project in Ruby I made a number of blog posts during development:
- Test-Driven Development
- Writing a parser generator in Ruby
- Progress notes
- Abstract Syntax Trees
- Putting the 'packrat' into PEG: adding memoizing to my Ruby parser generator
- Updated packrat performance numbers
- Parser generator update
- Another performance update: parity
- Here documents
- Goodbye parity, hello superiority
- Payoff time