English 中文(简体)
铁路3:一种景象,但并非全部。
原标题:Rails 3: Escape string in the view but not all

In a view, string is escaped by default.

mystring = "A&B: <b>some string here</b>" 
<%=mystring%>

www.un.org/Depts/DGACM/index_spanish.htm

A&amp;B: &lt;b&gt;some string here&lt;/b&gt;

然而,我需要有<条码>和t;b></b>所贴出的标签和amp。

A&amp;B: <b>some string here</b>

<代码>html_safe une Jerseys both ampersand and <b> tag。 是否有办法逃脱像安乐器这样的特殊特征,但不是html?

最佳回答

您可以使用鲁比·斯库什国际研究公司对具体要素的替罪羊:替罪羊 要素方法。 在你看来,你想利用以下手段:

mystring = CGI::escape_html("A&B: <b>some string here</b>")

# You can replace ["B"] with an array of tags to be escaped, i.e. ["B", "A", "IMG"]
mystring = CGI::unescapeElement(mystring, ["B"]) 

<%= mystring.html_safe %>

。 更紧急的方法。

问题回答

你们可以分成几个部分,然后是某些人想要的替罪羊。





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签