Module: DashingJson::ViewHelpers

Included in:
DashingJson
Defined in:
lib/dashing_json/view_helpers.rb

Instance Method Summary collapse

Instance Method Details

#dashing_json(data) ⇒ Object



4
5
6
# File 'lib/dashing_json/view_helpers.rb', line 4

def dashing_json(data)
  generate_html(data).html_safe
end

#generate_html(data) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/dashing_json/view_helpers.rb', line 8

def generate_html(data)
  data = data.to_json unless data and data.is_a?(String)
  
  "    <div class='dashing-json'>\n      <pre>\n        <ul class='dashing-json-parsed'></ul>\n        <div class='dashing-json-raw' data-dashing-json='\#{ JSON.pretty_generate(JSON.parse(data)) }'></div>\n      </pre>\n    </div>\n  HTML\nend\n"