From 9db208853b392333e2dccaf0b684bbfeaa2f48cc Mon Sep 17 00:00:00 2001 From: makoto kuwata Date: Mon, 5 May 2008 09:47:05 +0000 Subject: - [update] users-guide - [refactor] rails_helper.rb: remove debug messages - [change] rails_helper.rb: change 'logger.debug' to 'logger.info' --- CHANGES.txt | 27 +++++++------- ChangeLog.txt | 5 +++ ReleaseNote.txt | 74 ++++++++++++++++++++++++++++++++++++++ doc/users-guide.txt | 68 +++++++++++++++++++++++++++++++++++ lib/erubis/helpers/rails_helper.rb | 31 ++-------------- 5 files changed, 164 insertions(+), 41 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 59aa481..5ddd148 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -7,11 +7,16 @@ date: enhancements: + - | + Improved support of Ruby on Rails 2.0.2. + New class ActionView::TemplateHandlers::Erubis is defined and + registered as default handler of *.html.erb and *.rhtml. + - | '<%% %>' and '<%%= %>' are converted into '<% %>' and '<%= %>' respectively. This is for compatibility with ERB. - ex1.rhtml + ex1.rhtml: - | - '<%= -%>' removes tailing spaces and newlines. - This is for compatibiliy with ERB (and trim mode '-'). - '<%= =%>' also removes tailing spaces and newlines, and this is - Erubis-original enhancement (it is cooler than '<%= -%>', isn't it?). + '<%= -%>' removes tail spaces and newlines. + This is for compatibiliy with ERB when trim mode is '-'. + '<%= =%>' also removes tail spaces and newlines, and this is + Erubis-original enhancement (cooler than '<%= -%>', isn't it?). - ex2.rhtml + ex2.rhtml:
<%= @var -%> # or <%= @var =%>
@@ -53,13 +58,9 @@ - | Erubis::Eruby.load_file() now allows you to change cache filename. - eruby = Erubis::Eruby.load_file("ex3.rhtml", - :cachename=>'ex3.rhtml.cache') - - - - | - Support of Ruby on Rails 2.0.2 improved. - + ex. + eruby = Erubis::Eruby.load_file("ex3.rhtml", + :cachename=>'ex3.rhtml.cache') - release: 2.5.0 diff --git a/ChangeLog.txt b/ChangeLog.txt index 902c701..713e57c 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -2,6 +2,11 @@ .?lastupdate: $Date$ .?version: $Rev$ +: Rev.106 (2008-05-05) + .- [update] users-guide + .- [refactor] rails_helper.rb: remove debug messages + .- [change] rails_helper.rb: change 'logger.debug' to 'logger.info' + : Rev.105 (2008-05-03) .- [enhance] rails_helper.rb: improved Rails 2.0.2 support diff --git a/ReleaseNote.txt b/ReleaseNote.txt index 86f0e05..36feb57 100644 --- a/ReleaseNote.txt +++ b/ReleaseNote.txt @@ -1,3 +1,77 @@ +$ [ANN] Erubis 2.6.0 released - a fast and extensible eRuby + +I have released Erubis 2.6.0. +http://www.kuwata-lab.com/erubis/ +http://www.kuwata-lab.com/erubis/support/ +Erubis is another eRuby implementation which is very fast and +extensible than ERB and eruby. + +Enhancements from 2.5.0: + + + * Improved support of Ruby on Rails 2.0.2. + New class ActionView::TemplateHandlers::Erubis is defined and + registered as default handler of *.html.erb and *.rhtml. + + + * '<%% %>' and '<%%= %>' are converted into '<% %>' and '<%= %>' respectively. + This is for compatibility with ERB. + + ex1.rhtml: + + + result: + $ erubis ex1.rhtml + + + + * '<%= -%>' removes tailing spaces and newlines. + This is for compatibiliy with ERB when trim mode is '-'. + '<%= =%>' also removes tailing spaces and newlines, and this is + Erubis-original enhancement (cooler than '<%= -%>', isn't it?). + + ex2.rhtml: +
+ <%= @var -%> # or <%= @var =%> +
+ + result (version 2.6.0): + $ erubis -c '{var: "AAA\n"}' ex2.rhtml +
+ AAA +
+ + result (version 2.5.0): + $ erubis -c '{var: "AAA\n"}' ex2.rhtml +
+ AAA + +
+ + + * Erubis::Eruby.load_file() now allows you to change cache filename. + + ex. + eruby = Erubis::Eruby.load_file("ex3.rhtml", + :cachename=>'ex3.rhtml.cache') + + + +-- +regards, +makoto kuwata + + +.#-------------------------------------------------------------------------------- + $ [ANN] Erubis 2.5.0 released - a fast and extensible eRuby I have released Erubis 2.5.0. diff --git a/doc/users-guide.txt b/doc/users-guide.txt index 305ec9d..635fca9 100644 --- a/doc/users-guide.txt +++ b/doc/users-guide.txt @@ -2727,6 +2727,64 @@ Notice that pp_form_for() is not provided. .$ Other Topics | topics +.$$ '<%= =%>' and '<%= -%>' + +Since 2.6.0, '<%= -%>' remove tail spaces and newline. +This is for compatibiliy with ERB when trim mode is '-'. +'<%= =%>' also removes tail spaces and newlines, and this is +Erubis-original enhancement (cooler than '<%= -%>', isn't it?). + +.? tailnewline.rhtml +.-------------------- tailnewline.rhtml.comment_filter +
+<%= @var -%> # or <%= @var =%> +
+.-------------------- + +.? result (version 2.5.0): +.==================== +$ erubis -c '{var: "AAA\n"}' tailnewline.rhtml +
+AAA + +
+.==================== + +.? result (version 2.6.0): +.==================== tail_260.result +$ erubis -c '{var: "AAA\n"}' tailnewline.rhtml +
+AAA +
+.==================== + + +.$$ '<%% %>' and '<%%= %>' + +Since 2.6.0, '<%% %>' and '<%%= %>' are converted into '<% %>' and '<%= %>' respectively. +This is for compatibility with ERB. + +.? doublepercent.rhtml: +.-------------------- + +.-------------------- + +.? result: +.==================== +$ erubis doublepercent.rhtml + +.==================== + + + .$$ evaluate(context) v.s. result(binding) | topics-context-vs-binding It is recommended to use 'Erubis::Eruby#evaluate(context)' instead of 'Erubis::Eruby#result(binding)' because Ruby's Binding object has some problems. @@ -2898,6 +2956,7 @@ _buf.to_s .==================== + .$$ Syntax Checking | topics-syntax Command-line option '-z' checks syntax. It is similar to 'erubis -x file.rhtml | ruby -wc', but it can take several file names. @@ -2909,6 +2968,7 @@ Syntax OK .==================== + .$$ File Caching | topics-caching Erubis::Eruby.load_file(filename) convert file into Ruby script and return Eruby object. @@ -2926,6 +2986,14 @@ if test(?f, cachename) end .-------------------- +Since 2.6.0, it is able to specify cache filename. + +.? specify cache filename. +.-------------------- +filename = 'example.rhtml' +eruby = Erubis::Eruby.load_file(filename, :cachename=>filename+'.cache') +.-------------------- + Caching makes Erubis about 40-50 percent faster than no-caching. See {{}} for details. diff --git a/lib/erubis/helpers/rails_helper.rb b/lib/erubis/helpers/rails_helper.rb index a4445eb..d0155b1 100644 --- a/lib/erubis/helpers/rails_helper.rb +++ b/lib/erubis/helpers/rails_helper.rb @@ -81,38 +81,13 @@ module Erubis ## define class for backward-compatibility - class PreprocessingEruby < Erubis::PreprocessingEruby + class PreprocessingEruby < Erubis::PreprocessingEruby # :nodoc: end module TemplateConverter ## covert eRuby string into ruby code def _convert_template(template, view_obj=nil) # :nodoc: - #$stderr.puts "*** debug: self.class.name=#{self.class.name}" - # #=> ActionView::TemplateHandlers::Erubis - #$stderr.puts "*** debug: self.instance_variables=#{self.instance_variables.sort.inspect}" - # #=> ["@view"] - #$stderr.puts "*** debug: @view.class.name=#{@view.class.name}" - # #=> ActionView::Base - #$stderr.puts "*** debug: @view.instance_variables=#{@view.instance_variables.sort.inspect}" - # #=> ["@assigns", "@assigns_added", "@controller", "@first_render", "@logger", "@template_format", "@view_paths"] - # #=> =["@_cookies", "@_flash", "@_headers", "@_params", "@_request", "@_response", "@_session", "@action_name", "@assigns", "@assigns_added", "@before_filter_chain_aborted", "@content_for_layout", "@controller", "@first_render", "@ignore_missing_templates", "@logger", "@request_origin", "@stocks", "@template", "@template_class", "@template_format", "@url", "@variables_added", "@view_paths"] - #$stderr.puts "*** debug: self.methods=#{(self.methods.sort - Object.new.methods).inspect}" - # #=> ["_convert_template", "compile", "render"] - ##$stderr.puts "*** debug: self.methods=#{(self.methods.sort).inspect}" - #$stderr.puts "*** debug: @views.methods=#{(@views.methods.sort - Object.new.methods).inspect}" - ##$stderr.puts "*** debug: @views.methods=#{(@views.methods.sort).inspect}" - # #=> ["&", "^", "to_f", "to_i", "|"] - #$stderr.puts "*** debug: @first_render.class.name=#{@first_render.class.name.inspect}" - #$stderr.puts "*** debug: @view.controller.instance_variables=#{@view.controller.instance_variables.inspect}" - # #=> ["@stocks", "@_headers", "@template", "@_params", "@performed_redirect", "@before_filter_chain_aborted", "@_flash", "@assigns", "@_session", "@request_origin", "@_request", "@variables_added", "@_response", "@performed_render", "@url", "@action_name", "@_cookies"] - # #=> ["@stocks", "@_headers", "@template", "@_params", "@performed_redirect", "@before_filter_chain_aborted", "@_flash", "@assigns", "@_session", "@request_origin", "@_request", "@variables_added", "@_response", "@performed_render", "@url", "@action_name", "@_cookies"] - #$stderr.puts "*** debug: @view.controller.methods=#{@view.controller.methods.sort.inspect}" - #$stderr.puts "*** debug: self.object_id=#{self.object_id}" - #$stderr.puts "*** debug: @view.controller.instance_variable_get('@template').object_id=#{@view.controller.instance_variable_get('@template').object_id}" - #$stderr.puts "*** debug: @view.controller.instance_variable_get('@template').class=#{@view.controller.instance_variable_get('@template').class}" - - #src = ::Erubis::Eruby.new(template).src klass = ::Erubis::Helpers::RailsHelper.engine_class properties = ::Erubis::Helpers::RailsHelper.init_properties @@ -125,12 +100,12 @@ module Erubis #template = self.instance_eval(preprocessor.src) self_ = view_obj ? view_obj.controller.instance_variable_get('@template') : self template = preprocessor.evaluate(self_) - logger.debug "** Erubis: preprocessed==<<'END'\n#{template}END\n" if show_src + logger.info "** Erubis: preprocessed==<<'END'\n#{template}END\n" if show_src end ## convert into ruby code src = klass.new(template, properties).src #src.insert(0, '_erbout = ') - logger.debug "** Erubis: src==<<'END'\n#{src}END\n" if show_src + logger.info "** Erubis: src==<<'END'\n#{src}END\n" if show_src return src end end -- cgit v1.2.1