我已经继承了以下字符串(我也没有办法左右格式):转义HTML字符串
<iframe \n class=\"some_class\"\n type=\"text/html\" \n src=\"/embed/iframe_content.html?id=tsqA5D7_z10\" \n width=\"960\" \n height=\"593\" \n marginwidth=\"0\" \n marginheight=\"0\" \n frameborder=\"0\">\n</iframe>
我使其在ERB模板是这样的:
<%= the_string %>
在它像这样的文本呈现:
<iframe class="some_class" type="text/html" src="/embed/iframe_content.html?id=tsqA5D7_z10" width="960" height="593" marginwidth="0" marginheight="0" frameborder="0"></iframe>
我需要将其呈现为HTML。
我曾尝试以下:
<%= the_string.html_safe %>
#呈现字符串不变<%= CGI.unescapeHTML(the_string) %>
#有一个类型错误与类型错误' '不能DUP NilClass'<%= CGI.unescapeHTML(the_string).html_safe %>
#错误错误can not dup NilClass'<%= raw the_string %>
#呈现字符串不变
如何将此字符串呈现为HTML?
感谢您的这些建议。我会看看。 – Undistraction
再次感谢。 HTML Entites宝石是答案。 – Undistraction