Module: Gon::Escaper
- Extended by:
- ActionView::Helpers::JavaScriptHelper, ActionView::Helpers::TagHelper
- Defined in:
- lib/gon/escaper.rb
Class Method Summary collapse
- .escape_unicode(javascript) ⇒ Object
- .javascript_cdata_section(content, cdata) ⇒ Object
- .javascript_tag(content, type, cdata, nonce) ⇒ Object
Class Method Details
.escape_unicode(javascript) ⇒ Object
8 9 10 11 12 13 |
# File 'lib/gon/escaper.rb', line 8 def escape_unicode(javascript) if javascript result = escape_line_separator(javascript) javascript.html_safe? ? result.html_safe : result end end |
.javascript_cdata_section(content, cdata) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/gon/escaper.rb', line 23 def javascript_cdata_section(content, cdata) if cdata "\n//#{cdata_section("\n#{content}\n//")}\n" else "\n#{content}\n" end end |
.javascript_tag(content, type, cdata, nonce) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/gon/escaper.rb', line 15 def javascript_tag(content, type, cdata, nonce) = {} .merge!( { type: 'text/javascript' } ) if type .merge!( { nonce: nonce } ) if nonce content_tag(:script, javascript_cdata_section(content, cdata).html_safe, ) end |