lib/gon/helpers.rb in gon-1.1.0 vs lib/gon/helpers.rb in gon-1.1.1

- old
+ new

@@ -3,18 +3,28 @@ def self.included base base.send(:include, InstanceMethods) end module InstanceMethods - def include_gon - data = Gon.all_variables + def include_gon(camel_case = false) + if Gon.request_env + data = Gon.all_variables - script = "<script>window.gon = {};" - data.each do |key, val| - script += "gon." + key.to_s + '=' + val.to_json + ";" + script = "<script>window.gon = {};" + unless camel_case + data.each do |key, val| + script += "gon." + key.to_s + '=' + val.to_json + ";" + end + else + data.each do |key, val| + script += "gon." + key.to_s.camelize(:lower) + '=' + val.to_json + ";" + end + end + script += "</script>" + script.html_safe + else + "" end - script += "</script>" - script.html_safe end end end module GonHelpers \ No newline at end of file