# $Rev$ # $Release:$ # $Copyright$ # - release: 2.3.1 date: 2007-05-26 bugfix: - A serious bug in 'helpers/rails_helper.rb' is fixed. You must be update if you are using Erubis with Ruby on Rails. # - release: 2.3.0 date: 2007-05-23 enhancements: - | New class 'Erubis::FastEruby' is added. It is a subclass of Erubis::Eruby and includes InterpolationEnhancer. Erubis::FastEruby is compatible with and faster than Erubis::Eruby. - | New enhancer 'InterpolationEnhancer' is added. This enhancer uses expression interpolation to eliminate method call of String#<<. In the result, this enhancer makes Eruby a little faster. -------------------- ## Assume that input is '<%=name%>'. ## Eruby convert input into the following code. String#<< is called 5 times. _buf << ''; _buf << (name).to_s; _buf << ''; ## When InterpolationEnhancer is used, String#<< is called only once. _buf << %Q`#{name}`; -------------------- - | New enhancer 'ErboutEnhancer' is added. ErboutEnhancer set '_erbout' as well as '_buf' to be compatible with ERB. ex. ==================== $ cat ex.rhtml

Hello

$ erubis -x ex.rhtml _buf = ''; _buf << '

Hello

'; _buf.to_s $ erubis -xE Erbout ex.rhtml _erbout = _buf = ''; _buf << '

Hello

'; _buf.to_s ==================== - | [experimental] New enhancer 'DeleteIndentEnhancer' is added. This enhancer deletes indentation of HTML file. ex. ==================== $ cat ex.rhtml
$ erubis ex.rhtml
$ erubis -E DeleteIndent ex.rhtml
==================== - | Mod_ruby is supported (very thanks to Andrew R Jackson!). See users-guide and 'contrib/erubis-run.rb' for details. - | New command-line option '-X', '-N', '-U', and '-C' are added. These are intended to be a replacement of 'notext' command. '-X' shows only ruby statements and expressions. '-N' adds line numbers. '-U' compress empty lines into a line. '-C' removes empty lines. changes: - | 'helpers/rails_helper.rb' is changed to use ErboutEnhancer. The following is an examle to use Erubis with Ruby on Rails. File 'config/environment.rb': ---------------------------------------- require 'erubis/helpers/rails_helper' #Erubis::Helpers::RailsHelper.engine_class = Erubis::Eruby # or Erubis::FastEruby #Erubis::Helpers::RailsHelper.init_properties = {} #Erubis::Helpers::RailsHelper.show_src = false # set true for debugging ---------------------------------------- - | Command 'notext' has been removed. Use '-X', '-N', '-U', and '-C' instead. - | Tab characters in YAML file are expaneded automatically. If you want not to expand tab characters, add command-line optio '-T'. - | Benchmark scripts (benchmark/bench.*) are rewrited. - | Users-guide (doc/users-guide.html) is updated. # - release: 2.2.0 date: 2007-02-11 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 code into your 'config/environment.rb' and restart web server. This will set Erubis as eRuby compiler in Ruby on Rails instead of ERB. -------------------- 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 ActionView::Helpers::CaptureHelper are available. Methd ActionView::Helpers::TextHelper#concat() is also available. If Erubis::Helpers::RailsHelper.show_src is ture, Erubis prints converted Ruby code into log file (such as 'log/development.log'). - | 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. ex. -------------------- 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'). ex. ==================== $ cat context.rb @title = 'Example' @list = %w[AAA BBB CCC] $ cat example.rhtml

<%= @title %>

$ erubis -f context.rb example.rhtml

Example

==================== - | New command-line option '-c context' support. It takes context string in YAML inline style or Ruby code style. ex. YAML inline style ==================== $ erubis -c '{title: Example, list: [AAA, BBB, CCC]}' example.rhtml ==================== ex. Ruby style ==================== $ erubis -c '@title="Example"; @list=%w[AAA BBB CCC]' example.rhtml ==================== - | New command-line option '-z' (syntax checking) support. It is similar to 'erubis -x file.rhtml | ruby -wc', but it can take several filenames. ex. ==================== $ erubis -z app/views/*/*.rhtml Syntax OK ==================== - | New constant Erubis::VERSION added. changes: - | Class Erubis::Eruby changed to include Erubis::StringBufferEnhancer instead of Erubis::ArrayBufferEnhancer. This is for Ruby on Rails support. ex. ==================== $ cat example.rhtml $ erubis -x example.rhtml _buf = ''; _buf << ' '; _buf.to_s ==================== - | 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. # - release: 2.1.0 date: 2006-09-23 enhancements: - | Ruby on Rails support. Add the following code to your 'app/controllers/application.rb' and restart web server. -------------------- require 'erubis/helper/rails' suffix = 'erubis' ActionView::Base.register_template_handler(suffix, Erubis::Helper::RailsTemplate) #Erubis::Helper::RailsTemplate.engine_class = Erubis::EscapedEruby ## or Erubis::PI::Eruby #Erubis::Helper::RailsTemplate.default_properties = { :escape=>true, :escapefunc=>'h' } -------------------- And rename your view template as 'xxx.erubis'. If you got the "(eval):10:in `render': no block given" error, use '@content_for_layout' instead 'yield' in your layout template. - | Another eRuby engine (PIEngine) support. This engine doesn't break HTML design because it uses Processing Instructions (PI) '' as embedded pattern instead of '<% .. %>'. example.rhtml --------------------
@!{item}@
-------------------- compile: ==================== $ erubis -x --pi example.rhtml _buf = []; _buf << ' '; @list.each_with_index do |item, i| klass = i % 2 == 0 ? 'odd' : 'even' _buf << ' '; end _buf << '
'; _buf << (item).to_s; _buf << '
'; _buf.join ==================== - | Add new command 'notext' which remove text part from eRuby script and leaves only Ruby code. This is very useful for debug of eRuby script. example2.rhtml -------------------- <% @list.each_with_index do |item, i| %> <% klass = i % 2 == 0 ? 'odd' : 'even' %> <% end %>
<%== item %>
-------------------- command line example: ==================== $ notext example2.rhtml _buf = []; @list.each_with_index do |item, i| ; klass = i % 2 == 0 ? 'odd' : 'even' ; _buf << ( klass ).to_s; _buf << Erubis::XmlHelper.escape_xml( item ); end ; _buf.join $ notext -nc example2.rhtml 1: _buf = []; 4: @list.each_with_index do |item, i| ; 5: klass = i % 2 == 0 ? 'odd' : 'even' ; 6: _buf << ( klass ).to_s; 7: _buf << Erubis::XmlHelper.escape_xml( item ); 9: end ; 13: _buf.join ==================== - | Add new enhance 'NoCode' which removes ruby code from eRuby script and leaves only HTML text part. It is very useful to validate HTML of eRuby script. command-line example: ==================== $ erubis -x -E NoCode example2.rhtml
==================== changes: - License is changed to LGPL. - Command-line property '--escape=name' is renamed to '--escapefunc=name'. - When command-line option '-l perl' is specified, function 'encode_entities()' is used ad escaping function which is available wth HTML::Entities module. bugfix: - There is a certain pattern which makes Engine#convert() too slow. Now Engne#convert() is fixed not to be slown. - Command name is now displayed when '-h' is specified. # - release: 2.0.1 date: 2006-06-21 bugfix: - some minor bugs are fixed # - release: 2.0.0 date: 2006-05-20 changes: - module 'PrintEnhancer' is renamed to 'PrintEnabledEnahncer' - module 'FastEnhancer' and class 'FastEruby' is obsolete because they are integrated into Eruby class - Eruby#evaluate() calls instance_eval() instead of eval() - XmlEruby.escape_xml() is moved to XmlHelper.escape_xml() enhancements: - multi programming language support (Ruby/PHP/C/Java/Scheme/Perl/Javascript) - class Eruby runs very fast because FastEnhancer module is integrated into Eruby by default - TinyEruby class (tiny.rb) is added - module ArrayBufferEnhancer added - module ArrayEnhancer added - module BiPatternEnhancer added - module EscapeEnhancer added - module HeaderFooterEnhancer added - module NoTextEnhancer added - module PercentLineEnhancer added - module PrintEnabledEnhancer added - module PrintOutEnhancer added - module SimplifyEnhancer added - module StringBufferEnhancer added - module StringIOEnhancer added - command-line option '-b' (body only) added - command-line option '-e' (escape) added - command-line option '-l' (lang) added - command-line option '-E' (enhancer) added - command-line option '-I' (require path) added - command-line option '-K' (kanji code) added - command-line option '-S' (string to symbol) added - command-line option '-B' (call result(binding())) added # - release: 1.1.0 date: 2006-03-05 enhancements: - '<%# ... %>' is supported - PrintEnhancer, PrintEruby, and PrintXmlEruby added - release: 1.0.1 date: 2006-02-01 bugfixes: - bin/erubis is available with RubyGems # - release: 1.0.0 date: 2006-02-01 bugfixes: - first release