Sha256: bec413d9f5a9779df81069998b2ec176084ef7e9f990289e1e2b425047fc6615
Contents?: true
Size: 765 Bytes
Versions: 3
Compression:
Stored size: 765 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(/\\u2028/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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
gon-5.0.4 | lib/gon/escaper.rb |
gon-5.0.3 | lib/gon/escaper.rb |
gon-5.0.2 | lib/gon/escaper.rb |