Programming Tutorials

(追記) (追記ここまで)

escapeElement() in Ruby

By: Jeeva in Ruby Tutorials on 2009年03月03日 [フレーム]

escapeElement(string, *elements)

Escape only the tags of certain HTML elements in string.

Takes an element or elements or array of elements. Each element is specified by the name of the element, without angle brackets. This matches both the start and the end tag of that element. The attribute list of the open tag will also be escaped (for instance, the double-quotes surrounding attribute values).

 print CGI::escapeElement('<BR><A HREF="url"></A>', "A", "IMG")
 # "<BR>&lt;A HREF=&quot;url&quot;&gt;&lt;/A&gt"
 print CGI::escapeElement('<BR><A HREF="url"></A>', ["A", "IMG"])
 # "<BR>&lt;A HREF=&quot;url&quot;&gt;&lt;/A&gt"



(追記) (追記ここまで)


Add Comment

JavaScript must be enabled for certain features to work
* Required information
1000

Comments

No comments yet. Be the first!
(追記) (追記ここまで)
(追記) (追記ここまで)

AltStyle によって変換されたページ (->オリジナル) /