1.

How Do I Escape Html?

Answer»

USE RACK::Utils in your helpers as follows:

helpers do

def h(text)

Rack::Utils.escape_html(text)

end

end

Now you can escape HTML in your templates LIKE this:

<%= h scary_output %&GT;

Thanks to Chris Schneider for the tip!

Use Rack::Utils in your helpers as follows:

helpers do

def h(text)

Rack::Utils.escape_html(text)

end

end

Now you can escape HTML in your templates like this:

<%= h scary_output %>

Thanks to Chris Schneider for the tip!



Discussion

No Comment Found