Search code examples
ruby-on-railsrubytemplates

What is the meaning of "h" in "<%=h [ ...] %>"?


When I generate a default scaffold, the display tags on show.html.erb have

<%=h @broker.name %>

I know the difference between <% and <%=. What's the "h" do?


Solution

  • html escape. It's a method that converts things like < and > into numerical character references so that rendering won't break your html.