ERB 템플릿에서 나에게 HTML 조각을 생성하는 작은 Sinatra 앱이 있습니다.sinatra 앱에서 텍스트 데이터를 html_escape하는 방법은 무엇입니까?
어떻게 출력을 html_escape 할 수 있습니까?
< % = h somestring %> 헬퍼가시나 트라에 없습니다.
ERB 템플릿에서 나에게 HTML 조각을 생성하는 작은 Sinatra 앱이 있습니다.sinatra 앱에서 텍스트 데이터를 html_escape하는 방법은 무엇입니까?
어떻게 출력을 html_escape 할 수 있습니까?
< % = h somestring %> 헬퍼가시나 트라에 없습니다.
Rack::Utils
에는 HTML 이스케이프 메소드가 포함되어 있습니다. http://www.sinatrarb.com/faq.html#escape_html
require 'CGI'
get '/html' do
erb :view
end
def h(html)
CGI.escapeHTML html
end
__END__
@@view
<% File.open('my.html') do |f| %>
<%=h f.read() %>
<% end %>