Class: ActionView::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/locomotive/rails/action_view.rb

Overview

Constant Summary collapse

JSON_ESCAPE_MAP =
{
  "/" => '\/'
}

Instance Method Summary collapse

Instance Method Details

#escape_json(json) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/locomotive/rails/action_view.rb', line 16

def escape_json(json)
  if json
    result = json.gsub(/(\/|\342\200\250|\342\200\251)/u) { |match| JSON_ESCAPE_MAP[match] }
    json.html_safe? ? result.html_safe : result
  else
    ''
  end
end