Skip to content

Commit 9c14754

Browse files
committed
Simplify generated js
1 parent a4f0807 commit 9c14754

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/gon/helpers.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ module InstanceMethods
88
def include_gon
99
data = Rails.cache.read('gon_variables') || {}
1010

11-
script = "<script>function Gon(){"
11+
script = "<script>window.Gon = {};"
1212
data.each do |key, val|
13-
script += "this." + key.to_s + val.to_json + ";"
13+
script += "Gon." + key.to_s + val.to_json + ";"
1414
end
15-
script += "}; var Gon = new Gon()</script>"
15+
script += "</script>"
1616
script.html_safe
1717
end
1818
end

0 commit comments

Comments
 (0)