Forum: Ruby Erubis 2.2.0 release - a fast eRuby implementation

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
8e1efd5009e8efa38aa4393bc223f3c5?d=identicon&s=25 kwatch (Guest)
on 2007-02-12 12:09
(Received via mailing list)
Hi all,

I have released Erubis 2.2.0.

Erubis is another implementation of eRuby.

  * Very fast, almost three times faster than ERB and
    even ten percent faster than eruby (implemented in C)
  * Support multi-language
  * Auto escaping support
  * Auto trimming spaces around '<% %>'
  * Embedded pattern changeable (default '<% %>')
  * Context object available and easy to combine eRuby
    template with YAML datafile or Ruby script
  * Easy to extend in subclass
  * Ruby on Rails support

See users' guide (erubis_2.2.0/doc/users-guide.html)
for details.

$$ Enhancements

  * Performance tuned up. Release 2.2.0 works about 8 percent faster
    than 2.1.0.
    As a result, Erubis works more than 10 percent faster than eruby.
    (eruby is the extension module of eRuby written in C.)

  * Support of Ruby on Rails improved.
    If you want to use Erubis with Ruby on Rails, add the following
    into your 'config/environment.rb' and restart web server.
    This will set Erubis as eRuby compiler in Ruby on Rails instead of

    require 'erubis/helpers/rails_helper'
    #Erubis::Helpers::RailsHelper.engine_class = Erubis::Eruby
    #Erubis::Helpers::RailsHelper.init_properties = {}
    #Erubis::Helpers::RailsHelper.show_src = true

    Methods 'capture()' and 'content_for()' of
    are available. Methd ActionView::Helpers::TextHelper#concat() is
also available.

    If Erubis::Helpers::RailsHelper.show_src is ture, Erubis prints
    Ruby code into log file (such as 'log/development.log'). This is
for debug.

  * Erubis::Engine.load_file(filename) creates cache file (filename +
    '.cache') automatically if cache file is old or not exist.
    Caching makes Erubis about 40-50 percent faster.

    require 'erubis'
    eruby = Erubis::Eruby.load_file('example.rhtml')
       ## cache file 'example.rhtml.cache' is created automatically

  * Command-line option '-f datafile' can take Ruby script ('*.rb')
    as well as YAML file ('*.yaml' or '*.yml').

    $ cat context.rb
    @title = 'Example'
    @list  = %w[AAA BBB CCC]
    $ cat example.rhtml
    <h1><%= @title %></h1>
    <% for item in @list %>
      <li><%= item %></li>
    <% end %>
    $ erubis -f context.rb example.rhtml

  * New command-line option '-c context' support. It takes context
    in YAML inline style or Ruby code style.

    ex. YAML inline style
    $ erubis -c '{title: Example, list: [AAA, BBB, CCC]}'

    ex. Ruby style
    $ erubis -c '@title="Example"; @list=%w[AAA BBB CCC]'

  * New command-line option '-z' (syntax checking) support. It is
    to 'erubis -x file.rhtml | ruby -wc', but it can take several

    $ erubis -z app/views/*/*.rhtml
    Syntax OK

  * New constant Erubis::VERSION added.

$$ Changes

  * Class Erubis::Eruby changed to include
    instead of Erubis::ArrayBufferEnhancer.
    This is for Ruby on Rails support.

    $ cat example.rhtml
    <% for item in @list %>
      <li><%= item %></li>
    <% end %>
    $ erubis -x example.rhtml
    _buf = ''; _buf << '<ul>
    '; for item in @list
     _buf << '  <li>'; _buf << ( item ).to_s; _buf << '</li>
    '; end
     _buf << '</ul>

  * Erubis::StringBufferEnhancer#add_postamble() prints "_buf.to_s"
    instead of "_buf".
    This is useful for 'erubis -x file.rhtml | ruby -wc'.

  * Command-line option '-T' is removed. Use '--trim=false' instead.

  * License is changed to MIT License.

  * Embedded pattern '<%- -%>' can be handled.
This topic is locked and can not be replied to.