Ruby templating
I want a ruby templating system that is
- clean syntax, ideally with customizable special characters, and which ideally allows the template itself to be valid XML if i want
- quick and dirty (i.e. no XML based parsing step required)
- works for any type of text (i.e. no XML based parsing step required!!)
- support for templates as files (dont want to have to supply strings in memory)
- easy way to include other templates
- all the basic constructs must work well (conditionals, loops etc)
- powerful & extendable
All this you would expect if you are coming from Java or Python or Perl which have several excellent choices which tick all the boxes.
As of 25 Sep 2006 this seems to be the state of play:
erubis
More powerful and faster version of erb.
erb/eruby
Builtin to ruby distro. Insists on evaluating from a binding. eruby is marginally faster in my experience. Default ugly ASP/JSP like syntax. Has few features itself but you can craft on stuff as it uses the power of Ruby.
cs/Template :: http://cstemplate.rubyforge.org/
written in C but can’t do a simple conditional like [ if foo.length > 2 ]
PageTemplate :: http://coolnamehere.com/products/pagetemplate/
reasonable syntax, immature, unsupported, include other files? Proper object path navigation missing
Canny :: http://canny.sourceforge.net/documentation.shtml
Smarty port. Easy, file support (includes), conditionals. Unsupported.
Kwartz :: http://www.kuwata-lab.com/kwartz/
Tries to be too clever. Slow. Nesting gets complicated.
Amrita :: http://amrita.sourceforge.jp/
Tries to be too clever. Slow.
XTemplate :: http://xtemplate.sourceforge.net/
Tries to be too clever. Slow.
Conclusion
erubis seems to be the winner. Some of the other systems could be ok but have no momentum behind them.