Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

FAQ: don't include all Rack::Utils just for h().

The previous code doesn't seem like something we should recommend.

Other than the desired `h` helper, it would also give you a lot of unnecessary stuff like `set_cookie_header!`.
  • Loading branch information...
commit c5b071c5e1928515d8d0c60ba108cc8a1e81017b 1 parent 6346b79
Henrik Nyh authored December 16, 2012

Showing 1 changed file with 5 additions and 4 deletions. Show diff stats Hide diff stats

  1. 9  faq.markdown
9  faq.markdown
Source Rendered
@@ -245,12 +245,13 @@ And in `mailerapp.rb`:
245 245
 How do I escape HTML? {#escape_html}
246 246
 ---------------------
247 247
 
248  
-Include [Rack::Utils](http://rack.rubyforge.org/doc/classes/Rack/Utils.html)
249  
-in your helpers and create an `h` alias as follows:
  248
+Use [Rack::Utils](http://rack.rubyforge.org/doc/classes/Rack/Utils.html)
  249
+in your helpers as follows:
250 250
 
251 251
     helpers do
252  
-      include Rack::Utils
253  
-      alias_method :h, :escape_html
  252
+      def h(text)
  253
+        Rack::Utils.escape_html(text)
  254
+      end
254 255
     end
255 256
 
256 257
 Now you can escape HTML in your templates like this:

0 notes on commit c5b071c

Please sign in to comment.
Something went wrong with that request. Please try again.