summaryrefslogtreecommitdiff
path: root/doc
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 /doc
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
Diffstat (limited to 'doc')
-rw-r--r--doc/users-guide.html27
-rw-r--r--doc/users-guide.txt28
2 files changed, 40 insertions, 15 deletions
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 '< > & "'