summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormakoto kuwata <kwa@kuwata-lab.com>2008-05-05 09:47:05 +0000
committermakoto kuwata <kwa@kuwata-lab.com>2008-05-05 09:47:05 +0000
commit9db208853b392333e2dccaf0b684bbfeaa2f48cc (patch)
treebb4daadd05f4b8dfee2456a5e86b7be80561fbe9
parent64acc37f3f8236fdcb00179e8c4455f8937a4375 (diff)
downloaderubis-9db208853b392333e2dccaf0b684bbfeaa2f48cc.tar.gz
- [update] users-guide
- [refactor] rails_helper.rb: remove debug messages - [change] rails_helper.rb: change 'logger.debug' to 'logger.info'
-rw-r--r--CHANGES.txt27
-rw-r--r--ChangeLog.txt5
-rw-r--r--ReleaseNote.txt74
-rw-r--r--doc/users-guide.txt68
-rw-r--r--lib/erubis/helpers/rails_helper.rb31
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
@@ -8,10 +8,15 @@
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:
<ul>
<%% for item in @list %>
<li><%%= item %></li>
@@ -27,12 +32,12 @@
</ul>
- |
- '<%= -%>' 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:
<div>
<%= @var -%> # or <%= @var =%>
</div>
@@ -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:
+ <ul>
+ <%% for item in @list %>
+ <li><%%= item %></li>
+ <%% end %>
+ </ul>
+
+ result:
+ $ erubis ex1.rhtml
+ <ul>
+ <% for item in @list %>
+ <li><%= item %></li>
+ <% end %>
+ </ul>
+
+
+ * '<%= -%>' 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:
+ <div>
+ <%= @var -%> # or <%= @var =%>
+ </div>
+
+ result (version 2.6.0):
+ $ erubis -c '{var: "AAA\n"}' ex2.rhtml
+ <div>
+ AAA
+ </div>
+
+ result (version 2.5.0):
+ $ erubis -c '{var: "AAA\n"}' ex2.rhtml
+ <div>
+ AAA
+
+ </div>
+
+
+ * 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
+<div>
+<%= @var -%> # or <%= @var =%>
+</div>
+.--------------------
+
+.? result (version 2.5.0):
+.====================
+$ erubis -c '{var: "AAA\n"}' tailnewline.rhtml
+<div>
+AAA
+
+</div>
+.====================
+
+.? result (version 2.6.0):
+.==================== tail_260.result
+$ erubis -c '{var: "AAA\n"}' tailnewline.rhtml
+<div>
+AAA
+</div>
+.====================
+
+
+.$$ '<%% %>' and '<%%= %>'
+
+Since 2.6.0, '<%% %>' and '<%%= %>' are converted into '<% %>' and '<%= %>' respectively.
+This is for compatibility with ERB.
+
+.? doublepercent.rhtml:
+.--------------------
+<ul>
+<%% for item in @list %>
+ <li><%%= item %></li>
+<%% end %>
+</ul>
+.--------------------
+
+.? result:
+.====================
+$ erubis doublepercent.rhtml
+<ul>
+<% for item in @list %>
+ <li><%= item %></li>
+<% end %>
+</ul>
+.====================
+
+
+
.$$ 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 {{<benchmark|#topics-benchmark>}} 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