gon 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of gon might be problematic. Click here for more details.
- data/README.md +4 -5
- data/lib/gon/helpers.rb +7 -7
- data/lib/gon/version.rb +1 -1
- metadata +1 -1
data/README.md
CHANGED
@@ -9,9 +9,8 @@ If you need to send some data to your js files and you don't want to do this wit
|
|
9
9
|
``` erb
|
10
10
|
<head>
|
11
11
|
<title>some title</title>
|
12
|
-
<%=
|
13
|
-
|
14
|
-
<%= include_gon_js %> <!-- http://gaziev.com/files/gon.js -->
|
12
|
+
<%= include_gon %>
|
13
|
+
<!-- include your action js code -->
|
15
14
|
...
|
16
15
|
```
|
17
16
|
|
@@ -35,13 +34,13 @@ alert(Gon.your_other_variable)
|
|
35
34
|
Puts this line into `Gemfile` then run `$ bundle`:
|
36
35
|
|
37
36
|
``` ruby
|
38
|
-
gem 'gon', '0.
|
37
|
+
gem 'gon', '0.2.0'
|
39
38
|
```
|
40
39
|
|
41
40
|
Or if you are old-school Rails 2 developer put this into `config/environment.rb` and run `$ rake gems:install`:
|
42
41
|
|
43
42
|
``` ruby
|
44
|
-
config.gem 'gon', :version => '0.
|
43
|
+
config.gem 'gon', :version => '0.2.0'
|
45
44
|
```
|
46
45
|
|
47
46
|
Or manually install gon gem: `$ gem install gon`
|
data/lib/gon/helpers.rb
CHANGED
@@ -5,15 +5,15 @@ module Gon
|
|
5
5
|
end
|
6
6
|
|
7
7
|
module InstanceMethods
|
8
|
-
def
|
9
|
-
javascript_include_tag 'http://gaziev.com/files/gon.js'
|
10
|
-
end
|
11
|
-
|
12
|
-
def gon_variables
|
8
|
+
def include_gon
|
13
9
|
data = Rails.cache.read('gon_variables') || {}
|
14
10
|
|
15
|
-
|
16
|
-
|
11
|
+
script = "<script>function Gon(){"
|
12
|
+
data.each do |key, val|
|
13
|
+
script += "this." + key.to_s + "'" + val.to_s + "';"
|
14
|
+
end
|
15
|
+
script += "}; var Gon = new Gon()</script>"
|
16
|
+
script.html_safe
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
data/lib/gon/version.rb
CHANGED