Sha256: 079a3c628d138464657f0924e9a9573f05b5e30dce390619b89ce3b68c3d3cdb

Contents?: true

Size: 478 Bytes

Versions: 1

Compression:

Stored size: 478 Bytes

Contents

module Gon
  module Helpers
    def self.included base
      base.send(:include, InstanceMethods)
    end

    module InstanceMethods
      def include_gon
        data = Gon.all_variables || {}

        script = "<script>window.Gon = {};"
        data.each do |key, val|
          script += "Gon." + key.to_s + '=' + val.to_json + ";"
        end
        script += "</script>"
        script.html_safe
      end
    end

  end
end

ActionView::Base.send :include, Gon::Helpers

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gon-1.0.0 lib/gon/helpers.rb