# Template Engine in Ruby (similar to TT2)

**URL:** <https://www.ruby-forum.com/t/template-engine-in-ruby-similar-to-tt2/85446>\
**Category:** Ruby\
**Created:** [February 13, 2007, 5:04pm UTC](https://www.ruby-forum.com/t/template-engine-in-ruby-similar-to-tt2/85446 "2007-02-13T17:04:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ralf\_Robert\_HSSSSpp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/51bf81/32.png) [@Ralf\_Robert\_HSSSSpp](https://www.ruby-forum.com/u/Ralf_Robert_HSSSSpp)\
**Post date:** [February 13, 2007, 5:04pm UTC](https://www.ruby-forum.com/t/template-engine-in-ruby-similar-to-tt2/85446/1 "2007-02-13T17:04:16Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Ralf\_Robert\_HSSSSpp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/51bf81/32.png) [@Ralf\_Robert\_HSSSSpp](https://www.ruby-forum.com/u/Ralf_Robert_HSSSSpp)\
**Post date:** [February 13, 2007, 5:16pm UTC](https://www.ruby-forum.com/t/template-engine-in-ruby-similar-to-tt2/85446/2 "2007-02-13T17:16:19Z")

</div>

ERB is a general templating language.

[http://www.ruby-doc.org/stdlib/libdoc/erb/rdoc/](http://www.ruby-doc.org/stdlib/libdoc/erb/rdoc/)

Jason

---

<div class="post-metadata">

**Author:** ![Ralf\_Robert\_HSSSSpp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/51bf81/32.png) [@Ralf\_Robert\_HSSSSpp](https://www.ruby-forum.com/u/Ralf_Robert_HSSSSpp)\
**Post date:** [February 13, 2007, 6:05pm UTC](https://www.ruby-forum.com/t/template-engine-in-ruby-similar-to-tt2/85446/3 "2007-02-13T18:05:25Z")

</div>

On 2/13/07, Ralf Robert HÃ¶ppel [removed\_email\_address@domain.invalid](mailto: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.

> **[WebMD - Better information. Better health.](https://www.webmd.com/?HtmlTemplates)**
>
> The leading source for trustworthy and timely health and medical news and information. Providing credible health information, supportive community, and educational services by blending award-winning expertise in content, community services, expert...

however the wiki appears to be not responding right now so google cache  
has  
a recent copy [here](http://72.14.203.104/search?q=cache:4Utrub7qvyIJ:www.rubygarden.org/ruby%3FHtmlTemplates+ruby+html+template&hl=en&client=firefox-a&strip=1%3Chttp://72.14.203.104/search?q=cache:4Utrub7qvyIJ:www.rubygarden.org/ruby%253FHtmlTemplates+ruby+html+template&hl=en&client=firefox-a&strip=1%3E) (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

---

<div class="post-metadata">

**Author:** ![Ralf\_Robert\_HSSSSpp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/51bf81/32.png) [@Ralf\_Robert\_HSSSSpp](https://www.ruby-forum.com/u/Ralf_Robert_HSSSSpp)\
**Post date:** [February 13, 2007, 6:50pm UTC](https://www.ruby-forum.com/t/template-engine-in-ruby-similar-to-tt2/85446/4 "2007-02-13T18:50:29Z")

</div>

On Feb 13, 9:03 am, Ralf Robert Höppel [removed\_email\_address@domain.invalid](mailto: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? 😉

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