gon 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of gon might be problematic. Click here for more details.
- data/README.md +13 -7
- data/lib/gon/helpers.rb +3 -3
- data/lib/gon/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -17,16 +17,22 @@ If you need to send some data to your js files and you don't want to do this wit
|
|
17
17
|
In action of your controller you put something like this:
|
18
18
|
|
19
19
|
``` ruby
|
20
|
-
@
|
21
|
-
|
22
|
-
|
20
|
+
@your_int = 123
|
21
|
+
@your_array = [1,2]
|
22
|
+
@your_hash = {'a' => 1, 'b' => 2}
|
23
|
+
Gon.your_int = @your_int
|
24
|
+
Gon.your_other_int = 345 + @your_int
|
25
|
+
Gon.your_array = @your_array
|
26
|
+
Gon.your_hash = @your_hash
|
23
27
|
```
|
24
28
|
|
25
29
|
In javascript file for view of this action write call to your variable:
|
26
30
|
|
27
31
|
``` js
|
28
|
-
alert(Gon.
|
29
|
-
alert(Gon.
|
32
|
+
alert(Gon.your_int)
|
33
|
+
alert(Gon.your_other_int)
|
34
|
+
alert(Gon.your_array)
|
35
|
+
alert(Gon.your_hash)
|
30
36
|
```
|
31
37
|
|
32
38
|
## Installation
|
@@ -34,13 +40,13 @@ alert(Gon.your_other_variable)
|
|
34
40
|
Puts this line into `Gemfile` then run `$ bundle`:
|
35
41
|
|
36
42
|
``` ruby
|
37
|
-
gem 'gon', '0.2.
|
43
|
+
gem 'gon', '0.2.2'
|
38
44
|
```
|
39
45
|
|
40
46
|
Or if you are old-school Rails 2 developer put this into `config/environment.rb` and run `$ rake gems:install`:
|
41
47
|
|
42
48
|
``` ruby
|
43
|
-
config.gem 'gon', :version => '0.2.
|
49
|
+
config.gem 'gon', :version => '0.2.2'
|
44
50
|
```
|
45
51
|
|
46
52
|
Or manually install gon gem: `$ gem install gon`
|
data/lib/gon/helpers.rb
CHANGED
@@ -8,11 +8,11 @@ module Gon
|
|
8
8
|
def include_gon
|
9
9
|
data = Rails.cache.read('gon_variables') || {}
|
10
10
|
|
11
|
-
script = "<script>
|
11
|
+
script = "<script>window.Gon = {};"
|
12
12
|
data.each do |key, val|
|
13
|
-
script += "
|
13
|
+
script += "Gon." + key.to_s + val.to_json + ";"
|
14
14
|
end
|
15
|
-
script += "
|
15
|
+
script += "</script>"
|
16
16
|
script.html_safe
|
17
17
|
end
|
18
18
|
end
|
data/lib/gon/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-05-
|
12
|
+
date: 2011-05-11 00:00:00.000000000 +04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
description: If you need to send some data to your js files and you don't want to
|