Sha256: 33be1ce105db239e4b963e613f8c8d40c6bb181b8387fcf26828187dd0ff1bbe

Contents?: true

Size: 444 Bytes

Versions: 1

Compression:

Stored size: 444 Bytes

Contents

require 'json'

module DojoHelper

  def dojo_config(options = {})
    json = camelize_keys(options).to_json
    javascript_tag "dojoConfig = #{json};" 
  end

  def camelize_keys(hash)
    camelized_hash = hash.dup
    hash.each do |k, v|
      value = (v.kind_of?(Hash)) ? camelize_keys(v) : v
      key = k.to_s.camelize(:lower)

      camelized_hash[key] = value
      camelized_hash.delete(k)
    end

    return camelized_hash
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dojo-rails-0.14.0 app/helpers/dojo_helper.rb