Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #11620 (closed defect: duplicate)

Opened 1 week ago

Last modified 1 week ago

[PATCH] h method is not aliased properly

Reported by: aamer Assigned to: core
Priority: normal Milestone: 2.0.3
Component: ActionPack Version:
Severity: normal Keywords: erb html_escape
Cc:

Description

When you call html_escape(string) in a template, it will call the one defined in lib/action_view/template_handlers/erb.rb.

However, if you call h instead of html_escape, it will call the original method defined in the Ruby ERB library, not the on defined in action_view.

This should be properly aliased to make the two method calls identical. Here is a patch you can apply to lib/action_view/template_handlers/erb.rb if you are using actionpack 2.02:

--- erb.rb      2008-05-02 16:43:54.000000000 -0700
+++ erb_patched.rb      2008-05-02 16:44:07.000000000 -0700
@@ -7,6 +7,8 @@ class ERB
     def html_escape(s)
       s.to_s.gsub(/[&"><]/) { |special| HTML_ESCAPE[special] }
     end
+
+    alias_method :h, :html_escape
   end
 end

Change History

05/03/08 00:30:38 changed by aamer

  • summary changed from h method is not aliased properly to [PATCH] h method is not aliased properly.

05/03/08 08:12:19 changed by aamer

  • status changed from new to closed.
  • resolution set to duplicate.

Just realized trac is no longer used. Will re-post this on lighthouse.