Sha256: ce533553ae38da1bd86b137cb59887f36723610e7acc351e2760ffa788ef2945
Contents?: true
Size: 770 Bytes
Versions: 2
Compression:
Stored size: 770 Bytes
Contents
class Gon module Escaper extend ActionView::Helpers::JavaScriptHelper extend ActionView::Helpers::TagHelper class << self def escape_unicode(javascript) if javascript result = javascript.gsub(/\342\200\250/u, '
').gsub(/(<\/)/u, '\u003C/') javascript.html_safe? ? result.html_safe : result end end def javascript_tag(content, type, cdata) type = { type: 'text/javascript' } if type content_tag(:script, javascript_cdata_section(content, cdata).html_safe, type) end def javascript_cdata_section(content, cdata) if cdata "\n//#{cdata_section("\n#{content}\n//")}\n" else "\n#{content}\n" end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
gon-5.0.1 | lib/gon/escaper.rb |
gon-5.0.0 | lib/gon/escaper.rb |