如何在 sinatra 应用程序中 html_escape 文本数据? [英] How do I html_escape text data in a sinatra app?

查看:27
本文介绍了如何在 sinatra 应用程序中 html_escape 文本数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个小型 Sinatra 应用程序,它可以从 ERB 模板为我生成 html 片段.

I have a small Sinatra app which generates html fragments for me from an ERB template.

如何对输出进行 html_escape?

How do I html_escape the output?

<%=h somestring %> 助手在 Sinatra 中不存在.

The <%=h somestring %> helper does not exist in Sinatra.

推荐答案

Rack::Utils 包含一个 HTML 转义方法.http://www.sinatrarb.com/faq.html#escape_html

Rack::Utils includes a HTML escape method. http://www.sinatrarb.com/faq.html#escape_html

这篇关于如何在 sinatra 应用程序中 html_escape 文本数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆