Module | Erubis::XmlHelper |
In: |
erubis/helper.rb
|
helper for xml
ESCAPE_TABLE | = | { '&' => '&', '<' => '<', '>' => '>', '"' => '"', "'" => ''', } |
# File erubis/helper.rb, line 24 def escape_xml(value) value.to_s.gsub(/[&<>"]/) { |s| ESCAPE_TABLE[s] } # or /[&<>"']/ #value.to_s.gsub(/[&<>"]/) { ESCAPE_TABLE[$&] } end
# File erubis/helper.rb, line 29 def escape_xml2(value) return value.to_s.gsub(/\&/,'&').gsub(/</,'<').gsub(/>/,'>').gsub(/"/,'"') end