Skip to content

Commit

Permalink
added FAQ on how to escape html
Browse files Browse the repository at this point in the history
  • Loading branch information
beenimble authored and rtomayko committed Feb 10, 2009
1 parent 9da1620 commit b2de8f2
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions faq.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,23 @@ And in `mailerapp.rb`:

See the [book](book.html#deployment).

## <a id='escape_html' href='#escape_html'>How do I escape html?</a>

Include [Rack::Utils](http://rack.rubyforge.org/doc/classes/Rack/Utils.html)
in your helpers and create an `h` alias as follows:

helpers do
include Rack::Utils
alias_method :h, :escape_html
end

Now you can escape html in your templates like this:

<%= h scary_output %>

Thanks to [Christopher Schneid](http://www.gittr.com/index.php/archive/using-rackutils-in-sinatra-escape_html-h-in-rails/)
for the tip!

<!--
### <a id='queue' href='#queue'>How do I process jobs in the background?</a>
Expand Down

0 comments on commit b2de8f2

Please sign in to comment.