summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormakoto kuwata <kwa@kuwata-lab.com>2008-01-30 14:27:58 +0000
committermakoto kuwata <kwa@kuwata-lab.com>2008-01-30 14:27:58 +0000
commitf9611595d264ab5e1d7e90b524fa71b9dcd077ba (patch)
treed231676490fb2398087a24c63dc46656649b43d6
parent62ebde5610bb41ff0335ffd3d11699a532726975 (diff)
downloaderubis-f9611595d264ab5e1d7e90b524fa71b9dcd077ba.tar.gz
- [update] users-guide.txt: add tips about preprocessing in Rails 2.0
- [debug] rails_helper.rb: _decode(): change /%3C%25%3D(.*?)%25%3E/ to /%3C%25(?:=|%3D)(.*?)%25%3E/ - [release] release preparation for 2.5.0
-rw-r--r--CHANGES.txt44
-rw-r--r--ChangeLog.txt5
-rw-r--r--README.txt6
-rw-r--r--ReleaseNote.txt68
-rw-r--r--Rookbook.yaml21
-rw-r--r--doc/users-guide.html27
-rw-r--r--doc/users-guide.txt28
-rw-r--r--erubis.gemspec4
-rw-r--r--lib/erubis.rb2
-rw-r--r--lib/erubis/helpers/rails_helper.rb2
10 files changed, 157 insertions, 50 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 7abdcb8..5468714 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -4,44 +4,50 @@
- release: 2.5.0
- date: 2008-02-01
+ date: 2008-01-30
enhancements:
- |
- Ruby on Rails 2.0 supported.
+ Ruby on Rails 2.0 support.
+ If you are using preprocessing, notice that _?('foo.id') will be NG
+ because it contains period ('.') character.
+ --------------------
+ <!-- NG in Rails 2.0 -->
+ [%= link_to 'Edit', edit_user_path(_?('@user.id')) %]
+ [%= link_to 'Show', @user %]
+ [%= link_to 'Delete', @user, :confirm=>'OK?', :method=>:delete %]
+
+ <!-- OK in Rails 2.0 -->
+ <%= user_id = @user.id %>
+ [%= link_to 'Edit', edit_user_path(_?('user_id')) %]
+ [%= link_to 'Show', :action=>'show', :id=>_?('user_id') %]
+ [%= link_to 'Delete', {:action=>'destroy', :id=>_?('user_id')},
+ {:confirm=>'OK?', :method=>:delete} %]
+ --------------------
+
- |
+ (experimental)
Rails form helper methods for preprocessing are added.
These helper methos are available with preprocessing.
ex. _form.rhtml
--------------------
- <p>
- Name: <%= text_field :user, :name %>
- </p>
- <p>
- Name: [%= pp_text_field :user, :name %]
- </p>
+ Name: <%= text_field :user, :name %>
+ Name: [%= pp_text_field :user, :name %]
--------------------
preprocessed:
--------------------
- <p>
- Name: <%= text_field :user, :name %>
- </p>
- <p>
- Name: {{*<input id="stock_name" name="stock[name]" size="30" type="text" value="<%=h @stock.name%>" />*}}
- </p>
+ Name: <%= text_field :user, :name %>
+ Name: <input id="stock_name" name="stock[name]" size="30" type="text" value="<%=h @stock.name%>" />
--------------------
Ruby code:
--------------------
- _buf << ' <p>
+ _buf << '
Name: '; _buf << ( text_field :stock, :name ).to_s; _buf << '
- '; _buf << ' </p>
- <p>
Name: <input id="stock_name" name="stock[name]" size="30" type="text" value="'; _buf << (h @stock.name).to_s; _buf << '" />
- </p>
';
--------------------
@@ -50,7 +56,7 @@
so pp_text_field() with prepocessing is much faster than text_field().
See User's guide for details.
- http://www.kuwata-lab.local:8080/erubis/users-guide.05.html#rails-formhelpers
+ http://www.kuwata-lab.com/erubis/users-guide.05.html#rails-formhelpers
#
- release: 2.4.1
diff --git a/ChangeLog.txt b/ChangeLog.txt
index 78611f2..625df29 100644
--- a/ChangeLog.txt
+++ b/ChangeLog.txt
@@ -2,6 +2,11 @@
.?lastupdate: $Date$
.?version: $Rev$
+: Rev.99 (2008-01-29)
+ .- [update] users-guide.txt: add tips about preprocessing in Rails 2.0
+ .- [debug] rails_helper.rb: _decode(): change /%3C%25%3D(.*?)%25%3E/ to /%3C%25(?:=|%3D)(.*?)%25%3E/
+ .- [release] release preparation for 2.5.0
+
: Rev.98 (2008-01-29)
.- [enhance] add 'helpers/rails_form_helper.rb'
.- [change] helpers/rails_helper.rb: rename _expr() to _p()
diff --git a/README.txt b/README.txt
index 8a082dd..31cf282 100644
--- a/README.txt
+++ b/README.txt
@@ -27,9 +27,9 @@ See doc/users-guide.html for details.
== Installation
-* If you have installed RubyGems, just type <tt>gem install --remote erubis</tt>.
+* If you have installed RubyGems, just type <tt>gem install erubis</tt>.
- $ sudo gem install --remote erubis
+ $ sudo gem install erubis
* Else install abstract[http://rubyforge.org/projects/abstract/] at first,
and download erubis_X.X.X.tar.bz2 and install it by setup.rb.
@@ -62,7 +62,7 @@ and restart web server.
require 'erubis/helpers/rails_helper'
#Erubis::Helpers::RailsHelper.engine_class = Erubis::Eruby
#Erubis::Helpers::RailsHelper.init_properties = {}
- #Erubis::Helpers::RailsHelper.show_src = false
+ #Erubis::Helpers::RailsHelper.show_src = nil
If Erubis::Helpers::RailsHelper.show_src is ture, Erubis prints converted Ruby code
into log file ('log/development.log' or so). It is useful for debug.
diff --git a/ReleaseNote.txt b/ReleaseNote.txt
index 73e9d0f..c254389 100644
--- a/ReleaseNote.txt
+++ b/ReleaseNote.txt
@@ -1,3 +1,71 @@
+$ [ANN] Erubis 2.5.0 released - a fast and extensible eRuby
+
+I have released Erubis 2.5.0.
+http://www.kuwata-lab.com/erubis/
+Erubis is another eRuby implementation which is very fast and
+extensible than ERB and eruby.
+
+Enhancements from 2.4.1:
+
+ * Ruby on Rails 2.0 support
+ If you are using preprocessing, notice that _?('foo.id') will be NG
+ because it contains period ('.') character.
+
+ --------------------
+ <!-- NG in Rails 2.0 -->
+ [%= link_to 'Edit', edit_user_path(_?('@user.id')) %]
+ [%= link_to 'Show', @user %]
+ [%= link_to 'Delete', @user, :confirm=>'OK?', :method=>:delete %]
+
+ <!-- OK in Rails 2.0 -->
+ <%= user_id = @user.id %>
+ [%= link_to 'Edit', edit_user_path(_?('user_id')) %]
+ [%= link_to 'Show', :action=>'show', :id=>_?('user_id') %]
+ [%= link_to 'Delete', {:action=>'destroy', :id=>_?('user_id')},
+ {:confirm=>'OK?', :method=>:delete} %]
+ --------------------
+
+ * (experimental)
+ Rails form helper methods for preprocessing are added.
+ These helper methos are available with preprocessing.
+
+ ex. _form.rhtml
+ --------------------
+ Name: <%= text_field :user, :name %>
+ Name: [%= pp_text_field :user, :name %]
+ --------------------
+
+ preprocessed:
+ --------------------
+ Name: <%= text_field :user, :name %>
+ Name: <input id="stock_name" name="stock[name]" size="30"
+ type="text" value="<%=h @stock.name%>" />
+ --------------------
+
+ Ruby code:
+ --------------------
+ _buf << '
+ Name: '; _buf << ( text_field :stock, :name ).to_s; _buf << '
+ Name: <input id="stock_name" name="stock[name]" size="30"
+ type="text" value="';
+ _buf << (h @stock.name).to_s; _buf << '" />
+ ';
+ --------------------
+
+ This shows that text_filed() is called every time when rendering,
+ but pp_text_filed() is called only once when loading template,
+ so pp_text_field() with prepocessing is much faster than text_field().
+
+ See User's guide for details.
+ http://www.kuwata-lab.com/erubis/users-guide.05.html#rails-formhelpers
+
+
+--
+regards,
+makoto kuwata
+
+.--------------------------------------------------------------------------------
+
$ [ANN] Erubis 2.4.1 released - two bugs are fixed
I have released Erubis 2.4.1.
diff --git a/Rookbook.yaml b/Rookbook.yaml
index 5937da4..facdee0 100644
--- a/Rookbook.yaml
+++ b/Rookbook.yaml
@@ -20,7 +20,7 @@ parameters:
- abstract_rb : $(home)/src/abstract/trunk/lib/abstract.rb
- benchmark_files* : Dir.glob('benchmark/erubybench{-lib.rb,.rb,.rhtml,.yaml}')
- libfiles* : Dir.glob("lib/**/*")
- - base : $(project)_$(release)
+ - base : $(project)-$(release)
- base2 : $(project)-$(release)
#
- exclude_libs : # [cache.rb]
@@ -76,25 +76,25 @@ recipes:
chmod 0755, 'bin/*'
- - product: $(project)_*.tar.bz2
+ - product: $(project)-*.tar.bz2
desc: create *.tar.bz2
- ingreds: [ $(project)_$(1) ]
+ ingreds: [ $(project)-$(1) ]
method*: |
rm_f @product if test(?f, @product)
#tar_cjf @product, @ingred
sys "tar cjf #{@product} #{@ingred}"
- - product: $(project)_*.tar.gz
+ - product: $(project)-*.tar.gz
desc: create *.tar.gz
- ingreds: [ $(project)_$(1) ]
+ ingreds: [ $(project)-$(1) ]
method*: |
rm_f @product if test(?f, @product)
#tar_czf @product, @ingred
sys "tar czf #{@product} #{@ingred}"
- - product: $(project)_*.zip
+ - product: $(project)-*.zip
desc: create *.zip
- ingreds: [ $(project)_$(1) ]
+ ingreds: [ $(project)-$(1) ]
method*: |
rm_f @product if test(?f, @product)
#zip_r @product, @ingred
@@ -103,11 +103,12 @@ recipes:
- product: $(project)-*.gem
desc: create *.gem
- ingreds: [ $(project)_$(1) ]
+ ingreds: [ $(project)-$(1) ]
method*: |
dir = @ingred
cd dir do
Gem.manage_gems
+ require 'rubygems/gem_runner'
Gem::GemRunner.new.run ['build', '$(project).gemspec']
end
mv "#{dir}/#{@product}", "."
@@ -116,12 +117,12 @@ recipes:
method*: |
chdir "doc" do sys "rook :all" end
- - product: $(project)_*
+ - product: $(project)-*
ingreds: [ $(text_files), $(doc_files), :apidoc ]
method*: |
comment 'delete and create directory'
release = '$(1)' # @matches[1]
- dir = "$(project)_#{release}"
+ dir = "$(project)-#{release}"
rm_rf dir if test(?d, dir)
mkdir_p dir
#
diff --git a/doc/users-guide.html b/doc/users-guide.html
index 7f18497..9cf5065 100644
--- a/doc/users-guide.html
+++ b/doc/users-guide.html
@@ -2449,13 +2449,28 @@ because tag helpers generate different html code when form parameter has errors
Preprocessing is not available with these methods.
</li>
</ul>
-<p><span style="color:#FF0000">CAUTHON:</span> link_to() in Ruby on Rails 2.0 doesn't work correctly with preprocessing.
+<p>In Ruby on Rails 2.0, <code>_?('user_id')</code> is OK but <code>_?('user.id')</code> is NG
+because the latter contains period ('.') character.
</p>
+<pre class="program">&lt;!-- NG in Rails 2.0, because _?('') contains period --&gt;
+[%= link_to 'Edit', edit_user_path(<strong>_?('@user.id')</strong>) %]
+[%= link_to 'Show', <strong>@user</strong> %]
+[%= link_to 'Delete', <strong>@user</strong>, :confirm=&gt;'OK?', :method=&gt;:delete %]
+
+&lt;!-- OK in Rails 2.0 --&gt;
+<strong>&lt;%= user_id = @user.id %&gt;</strong>
+[%= link_to 'Edit', edit_user_path(<strong>_?('user_id')</strong>) %]
+[%= link_to 'Show', <strong>:action=&gt;'show', :id=&gt;_?('user_id')</strong> %]
+[%= link_to 'Delete', <strong>{:action=&gt;'destroy', :id=&gt;_?('user_id')}</strong>,
+ {:confirm=&gt;'OK?', :method=&gt;:delete} %]
+</pre>
<br>
<a name="rails-formhelpers"></a>
<h3 class="section2">Form Helpers for Preprocessing</h3>
+<p><strong>(Experimental)</strong>
+</p>
<p>Erubis provides form helper methods for preprocessing.
These are defined in 'erubis/helpers/rails_form_helper.rb'.
If you want to use it, require it and include Erubis::Helpers::RailsFormHelper in 'app/helpers/applition_helper.rb'
@@ -2544,7 +2559,7 @@ This means that pp_text_field() with preprocessing makes view layer very fast.
</ul>
<p>Notice that pp_form_for() is not provided.
</p>
-<p><span style="color:#FF0000">CAUTION:</span> These are not tested in Ruby on Rails 2.0.
+<p><span style="color:#FF0000">CAUTION:</span> These are experimental and may not work in Ruby on Rails 2.0.
</p>
<br>
@@ -2556,10 +2571,6 @@ This means that pp_text_field() with preprocessing makes view layer very fast.
</li>
</ul>
<ul type="disc">
-<li>link_to() method in Ruby on Rails 2.0 doesn't work correctly with preprocessing.
-</li>
-</ul>
-<ul type="disc">
<li>Form helper methods are not tested in Ruby on Rails 2.0.
</li>
</ul>
@@ -2572,8 +2583,6 @@ This means that pp_text_field() with preprocessing makes view layer very fast.
end
alias h html_escape
</pre>
-</li>
-</ul>
<p> New definition in 'erubis/helpers/rails_helper.rb' is faster than the above
because it scans string only once.
</p>
@@ -2587,6 +2596,8 @@ This means that pp_text_field() with preprocessing makes view layer very fast.
You should use ERB::Util.html_hscape() if string contains a lot of '&lt; &gt; &amp; "'
characters.
</p>
+</li>
+</ul>
<br>
diff --git a/doc/users-guide.txt b/doc/users-guide.txt
index 5ad14b8..305ec9d 100644
--- a/doc/users-guide.txt
+++ b/doc/users-guide.txt
@@ -2589,12 +2589,28 @@ Helper methods of Ruby on Rails are divided into two groups.
because it may return differrent value even if the same arguments are passed.
Preprocessing is not available with these methods.
+In Ruby on Rails 2.0, {{,_?('user_id'),}} is OK but {{,_?('user.id'),}} is NG
+because the latter contains period ('.') character.
-{{!CAUTHON:!}} link_to() in Ruby on Rails 2.0 doesn't work correctly with preprocessing.
+.--------------------
+<!-- NG in Rails 2.0, because _?('') contains period -->
+[%= link_to 'Edit', edit_user_path({{*_?('@user.id')*}}) %]
+[%= link_to 'Show', {{*@user*}} %]
+[%= link_to 'Delete', {{*@user*}}, :confirm=>'OK?', :method=>:delete %]
+
+<!-- OK in Rails 2.0 -->
+{{*<%= user_id = @user.id %>*}}
+[%= link_to 'Edit', edit_user_path({{*_?('user_id')*}}) %]
+[%= link_to 'Show', {{*:action=>'show', :id=>_?('user_id')*}} %]
+[%= link_to 'Delete', {{*{:action=>'destroy', :id=>_?('user_id')}*}},
+ {:confirm=>'OK?', :method=>:delete} %]
+.--------------------
.$$ Form Helpers for Preprocessing | rails-formhelpers
+{{*(Experimental)*}}
+
Erubis provides form helper methods for preprocessing.
These are defined in 'erubis/helpers/rails_form_helper.rb'.
If you want to use it, require it and include Erubis::Helpers::RailsFormHelper in 'app/helpers/applition_helper.rb'
@@ -2671,15 +2687,13 @@ Module Erubis::Helpers::RailsFormHelper defines the following form helper method
Notice that pp_form_for() is not provided.
-{{!CAUTION:!}} These are not tested in Ruby on Rails 2.0.
+{{!CAUTION:!}} These are experimental and may not work in Ruby on Rails 2.0.
.$$ Others | rails-others
.* ActionView::Helpers::CaptureHelper#capture() and ActionView::Helpers::Texthelper#concat() are available.
-.* link_to() method in Ruby on Rails 2.0 doesn't work correctly with preprocessing.
-
.* Form helper methods are not tested in Ruby on Rails 2.0.
.* ERB::Util.h() is redefined if you require 'erubis/helpers/rails_helper.rb'.
@@ -2692,17 +2706,17 @@ Notice that pp_form_for() is not provided.
end
alias h html_escape
.--------------------
-
+
New definition in 'erubis/helpers/rails_helper.rb' is faster than the above
because it scans string only once.
-
+
.--------------------
ESCAPE_TABLE = { '&'=>'&amp;', '<'=>'&lt;', '>'=>'&gt;', '"'=>'&quot;', "'"=>'&#039;', }
def h(value)
value.to_s.gsub(/[&<>"]/) { |s| ESCAPE_TABLE[s] }
end
.--------------------
-
+
Notice that the new definition may be slow if string contains
many '< > & "' characters because block is call many time.
You should use ERB::Util.html_hscape() if string contains a lot of '< > & "'
diff --git a/erubis.gemspec b/erubis.gemspec
index b07001d..8dd1afa 100644
--- a/erubis.gemspec
+++ b/erubis.gemspec
@@ -2,7 +2,7 @@
###
### $Rev$
-### $Release$
+### $Release: $
### $Copyright$
###
@@ -12,10 +12,12 @@ spec = Gem::Specification.new do |s|
## package information
s.name = "erubis"
s.author = "makoto kuwata"
+ s.email = "kwa(at)kuwata-lab.com"
s.version = "$Release$"
s.platform = Gem::Platform::RUBY
s.homepage = "http://www.kuwata-lab.com/erubis/"
s.summary = "a fast and extensible eRuby implementation which supports multi-language"
+ s.rubyforge_project = 'erubis'
s.description = <<-'END'
Erubis is an implementation of eRuby and has the following features:
diff --git a/lib/erubis.rb b/lib/erubis.rb
index e3f5e6e..337536c 100644
--- a/lib/erubis.rb
+++ b/lib/erubis.rb
@@ -1,6 +1,6 @@
##
## $Rev$
-## $Release$
+## $Release:$
## $Copyright$
##
diff --git a/lib/erubis/helpers/rails_helper.rb b/lib/erubis/helpers/rails_helper.rb
index a055f85..63dc1b7 100644
--- a/lib/erubis/helpers/rails_helper.rb
+++ b/lib/erubis/helpers/rails_helper.rb
@@ -266,7 +266,7 @@ class ActionView::Base # :nodoc:
alias _? _p
def _decode(arg)
arg = arg.to_s
- arg.gsub!(/%3C%25%3D(.*?)%25%3E/) { "<%=#{CGI.unescape($1)}%>" }
+ arg.gsub!(/%3C%25(?:=|%3D)(.*?)%25%3E/) { "<%=#{CGI.unescape($1)}%>" }
arg.gsub!(/&lt;%=(.*?)%&gt;/) { "<%=#{CGI.unescapeHTML($1)}%>" }
return arg
end