Sha256: ca056e754644f9cb80fc9bbdd5ab63ff0bfe6f8aa23a3de295827a4d6dcd7392
Contents?: true
Size: 851 Bytes
Versions: 6
Compression:
Stored size: 851 Bytes
Contents
class Gon module Escaper extend ActionView::Helpers::JavaScriptHelper extend ActionView::Helpers::TagHelper class << self def escape_unicode(javascript) if javascript result = escape_line_separator(javascript) 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 private def escape_line_separator(javascript) javascript.gsub(/\\u2028/u, '
') end end end end
Version data entries
6 entries across 6 versions & 1 rubygems
Version | Path |
---|---|
gon-5.2.3 | lib/gon/escaper.rb |
gon-5.2.2 | lib/gon/escaper.rb |
gon-5.2.1 | lib/gon/escaper.rb |
gon-5.2.0 | lib/gon/escaper.rb |
gon-5.1.2 | lib/gon/escaper.rb |
gon-5.1.1 | lib/gon/escaper.rb |