%p To your <code>Gemfile</code> add

%pre
  :preserve
    gem 'rest-client'
    gem 'json'

%p
  Then run <code>bundle install</code>. Use the following code snippet to get data
  from the API.

- block = capture do
  %pre
    :preserve
      # Get data from the morph.io api
      require 'rest-client'
      require 'json'

      # We're always asking for json because it's the easiest to deal with
      morph_api_url = '#{api_root}[full_name]/data.json'

      # Keep this key secret!
      morph_api_key = '[api_key]'

      result = RestClient.get morph_api_url, params:
        {
          key: morph_api_key,
          query: %q[[query]]
        }

      p JSON.parse(result)

= block.sub('[full_name]', "<span class='full_name'>#{h(@scraper.full_name)}</span>").sub('[api_key]', "<span class='unescaped-api_key'>#{current_user ? current_user.api_key : '[api_key]'}</span>").sub('[query]', "<span class='unescaped-query'>#{h(@query)}</span>").html_safe

%p To your <code>Gemfile</code> add

:coderay
  #!ruby
  gem 'rest-client'
  gem 'json'

%p
  Then run <code>bundle install</code>. Use the following code snippet to get data
  from the API.

- block = capture do
  :coderay
    #!ruby
    # Get data from the morph.io api
    require 'rest-client'
    require 'json'

    # We're always asking for json because it's the easiest to deal with
    morph_api_url = '#{api_root}[full_name]/data.json'

    # Keep this key secret!
    morph_api_key = '[api_key]'

    result = RestClient.get morph_api_url, params:
      {
        key: morph_api_key,
        query: %q[[query]]
      }

    p JSON.parse(result)

= block.sub('[full_name]', "<span class='full_name'>#{h(@scraper.full_name)}</span>").sub('[api_key]', "<span class='unescaped-api_key'>#{current_user ? current_user.api_key : '[api_key]'}</span>").sub('[query]', "<span class='unescaped-query'>#{h(@query)}</span>").html_safe

Use coderay on ruby example
Use coderay on ruby example
