Template Engine in Ruby (similar to TT2)


#1

Hi all,

is there a template engine similar to Template Toolkit 2 (in Perl)
available for Ruby? It should be feature-rich, stand-alone, not
restricted to only generate HTML output.

I know there are solutions around (everybody writes his own, I suppose),
but it is difficult to get an overview on what is available.

Thanks —
Ralf.


#2

ERB is a general templating language.

http://www.ruby-doc.org/stdlib/libdoc/erb/rdoc/

Jason


#3

On 2/13/07, Ralf Robert Höppel removed_email_address@domain.invalid wrote:

Ralf,

There is a nice assortment of template engines in Ruby. A good overview
of
the more common ones is on this wiki page. Many of these can be used for
both html and non-html output and they mention that in their features.

http://www.rubygarden.org/ruby?HtmlTemplates

however the wiki appears to be not responding right now so google cache
has
a recent copy here (or search google for ruby html templates and
you’ll
find it)

This site lists a quick snippet of their syntax and the major features
along
with links to the sites.

Jeff


#4

On Feb 13, 9:03 am, Ralf Robert Höppel removed_email_address@domain.invalid wrote:

is there a template engine similar to Template Toolkit 2 (in Perl) available for Ruby? It should be feature-rich, stand-alone, not restricted to only generate HTML output.

I’m not familiar with Perl or TT2. However, I will say that ERB (that
comes with Ruby) sounds like a good match. I use it at work for both
HTML and C++ code generation.

Because it was so common for me to want to use an XML file to drive an
ERB template, I wrote a little script that loads a specified XML file
into REXML, and makes that available to an ERB template.

It’s simple, but it’s Ruby…how much more simplicity and power do you
need? :wink:

I’ve uploaded documentation and code for it at
http://phrogz.net/AnarkSamples/RubyGen/