Skip to content

Commit 83cd75e

Browse files
committed
Added support for different types
1 parent 56b287b commit 83cd75e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/gon/helpers.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ def include_gon
1010

1111
script = "<script>function Gon(){"
1212
data.each do |key, val|
13-
script += "this." + key.to_s + "'" + val.to_s + "';"
14-
end
13+
val = "'#{val}'" if val.instance_of? String
14+
script += "this." + key.to_s + val.to_json + ";"
15+
end
1516
script += "}; var Gon = new Gon()</script>"
1617
script.html_safe
1718
end

0 commit comments

Comments
 (0)