module DashingJson::ViewHelpers

Public Instance Methods

dashing_json(data) click to toggle source
# File lib/dashing_json/view_helpers.rb, line 4
def dashing_json(data)
  generate_html(data).html_safe
end
generate_html(data) click to toggle source
# File lib/dashing_json/view_helpers.rb, line 8
    def generate_html(data)
      data = data.to_json unless data and data.is_a?(String)
      
      <<-HTML
        <div class='dashing-json'>
          <pre>
            <ul class='dashing-json-parsed'></ul>
            <div class='dashing-json-raw' data-dashing-json='#{ JSON.pretty_generate(JSON.parse(data)) }'></div>
          </pre>
        </div>
      HTML
    end