在埃尔朗Escape Html [英] Escape Html in erlang

查看:159
本文介绍了在埃尔朗Escape Html的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人有一个很好的方式来转移erlang中的html标签(对于Ruby中的CGI.escapeHtml)?



谢谢

解决方案

嗯,我会告诉你使用字符串和列表处理来滚动自己的方法但是,我也会说如果你有yaws的web服务器源,有一个方法我已经使用并复制到我自己的库中。 yaws_api:url_encode(HtmlString)

在这里看到它。

 
1> Html =5> 4 = true。
5> 4 = true
2> yaws_api:url_encode(Html)。
5%20%3E%204%20%3D%20true
3>


我希望这是你需要的一些。如果这是你需要的,你可以浏览雅虎Web服务器的源代码,然后复制这个功能并在你自己的项目中使用它,注意在模块 yaws_api.erl ,你必须确保你复制这个函数的所有依赖项,因为klacke做了大量的模式匹配,函数子句,递归等只需从该源文件复制整个函数和小型支持函数,并将其粘贴到项目的某个位置。另一种方式是通过操作字符串和列表来自己来做。这些是我的建议:)


Does anyone have a good way to escape html tags in erlang (as for CGI.escapeHtml in Ruby)?

Thanks

解决方案

Well, i would tell you to roll your own method using string and list processing But, i would also say that if you have yaws web server source, there is a method i have used and copied into my own libraries. yaws_api:url_encode(HtmlString).

See it here in action.

1> Html = "5 > 4 = true".
"5 > 4 = true"
2> yaws_api:url_encode(Html).
"5%20%3E%204%20%3D%20true"
3> 

I hope this is some how what u needed. If this is what you needed, you could just browse yaws web server source code and then copy out this function and use it in your own projects, notice that within the module yaws_api.erl, you will have to make sure that you copy out all the dependencies for this function as klacke did a lot of pattern matching, function clauses, recursion e.t.c. Just copy the whole function and the small support functions from that source file and paste it some where in your projects. The other way would be to do it by your own by manipulating strings and Lists. Those are my suggestions :)

这篇关于在埃尔朗Escape Html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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