如何在 SLIM 中呈现 HTML 编码的文本
How to render HTML encoded text in SLIM
在我的 rails 应用程序中,我使用 slim 进行模板渲染。
现在我有一个字段有一些 HTML 标签。
@description = "This is first line <br> second line. some <b>more</b> formatting."
在view.html.slim
p = @description
正在生成以下输出
This is first line <br> second line. some <b>more</b> formatting.
如我所愿
This is first line
second line. some more formatting.
我的问题是: 如何在 slim 中呈现这个 html 编码的文本?
谢谢
尝试
p = @description.html_safe
在我的 rails 应用程序中,我使用 slim 进行模板渲染。 现在我有一个字段有一些 HTML 标签。
@description = "This is first line <br> second line. some <b>more</b> formatting."
在view.html.slim
p = @description
正在生成以下输出
This is first line <br> second line. some <b>more</b> formatting.
如我所愿
This is first line
second line. some more formatting.
我的问题是: 如何在 slim 中呈现这个 html 编码的文本?
谢谢
尝试
p = @description.html_safe