在Sinatra中,使用erubis,escape_html
的默認設置是true
。在使用erubis的sinatra中,默認設置是escape_html。有時需要使用unescape
但有時我想要unescape,因爲我不想添加太多的escape_html。不要重複自己。 :)
helpers:
def raw(string)
CGI::unescape_html(string)
end
views:
<div class="body">
<%= raw "<h1>Thanks for help...</h1>" %>
</div>
不起作用。