ERB provides an easy to use but powerful templating system for Ruby.
Rails/RoR, the web application framework, uses ERB to create views.
Shamelessly compiled and copied from:
ERB recognizes certain tags in the provided template and converts
them based on the rules below:
<% Ruby code -- inline with output %>
<%= Ruby expression -- replace with result %>
<%# comment -- ignored -- useful in testing %>
% a line of Ruby code -- treated as <% line %> (optional -- see ERB.new)
%% replaced with % if first thing on a line and % processing is used
<%% or %%> -- replace with <% or %> respectively
<%- and -%> suppress leading and trailing whitespace, including the trailing newline, and can be used interchangeably with <% and %>.
All other text is passed through ERB filtering unchanged.
There are a variety of templating solutions available in various Ruby projects:
* ERB‘s big brother, eRuby, works the same but is written in C for speed;
* Erubis is a fast, secure, and very extensible implementation of eRuby
* Amrita (smart at producing HTML/XML);
* cs/Template (written in C for speed);
* RDoc uses its own template engine, which can be reused elsewhere;
* and others; search the RAA.