【发布时间】:2011-10-06 18:44:32
【问题描述】:
我有一个执行 HTTP 调用的简单 Sinatra 应用程序,我想通过 Haml 在应用程序中显示响应标头和正文。这是我需要显示的 HTTP 输出
Response header
#<Net::HTTPMovedPermanently:0x00000105852158>
Response body
<html>
<head>
<title>bit.ly</title>
</head>
<body>
<a href="http://www.csmonitor.com/Science/2011/1004/Nobel-Prize-for-physics-Universe-expansion-accelerating-not-slowing-down">moved here</a>
</body>
</html>
在 Haml 中执行此操作的正确方法是什么?这是我目前拥有的,它没有正确处理原始 html 输出
@@ layout
!!! 1.1
%html
%head
%title Just do it!
%link{:rel => 'stylesheet', :href => 'http://www.w3.org/StyleSheets/Core/Modernist', :type => 'text/css'}
= yield
@@ index
Header:
%p= @resp.header
Body:
%p= @resp.body
我曾尝试使用 html_safe 和 raw,但它们在 Sinatra 中不可用。
【问题讨论】: