gon 0.1.0 → 0.1.1

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 CHANGED
@@ -1,10 +1,34 @@
1
1
  # Gon gem — get your Rails variables in your js
2
2
 
3
- TODO: write description
3
+ If you need to send some data to your js files and you don't want to do this with long way trough views and parsing - use this force!
4
4
 
5
5
  ## Usage
6
6
 
7
- TODO: write usage
7
+ `app/views/layouts/application.html.erb`
8
+
9
+ ``` erb
10
+ <head>
11
+ <title>some title</title>
12
+ <%= gon_variables %>
13
+ <%= javascript_include_tag 'http://code.jquery.com/jquery-1.6.min.js' %> <!-- include jquery -->
14
+ <%= include_gon_js %> <!-- http://gaziev.com/files/gon.js -->
15
+ ...
16
+ ```
17
+
18
+ In action of your controller you put something like this:
19
+
20
+ ``` ruby
21
+ @your_variable = 123
22
+ Gon.your_variable = @your_variable
23
+ Gon.your_other_variable = 345 + @your_variable
24
+ ```
25
+
26
+ In javascript file for view of this action write call to your variable:
27
+
28
+ ``` js
29
+ alert(Gon.your_variable)
30
+ alert(Gon.your_other_variable)
31
+ ```
8
32
 
9
33
  ## Installation
10
34
 
@@ -20,7 +44,7 @@ Or if you are old-school Rails 2 developer put this into `config/environment.rb`
20
44
  config.gem 'gon', :version => '0.1.0'
21
45
  ```
22
46
 
23
- Or manually install variants gem: `$ gem install gon`
47
+ Or manually install gon gem: `$ gem install gon`
24
48
 
25
49
  ## Contributors
26
50
 
data/lib/gon/helpers.rb CHANGED
@@ -5,14 +5,15 @@ module Gon
5
5
  end
6
6
 
7
7
  module InstanceMethods
8
- def include_gon
8
+ def include_gon_js
9
9
  javascript_include_tag 'http://gaziev.com/files/gon.js'
10
10
  end
11
11
 
12
12
  def gon_variables
13
13
  data = Rails.cache.read('gon_variables') || {}
14
14
 
15
- data.to_s.gsub('=>', ' : ')
15
+ '<gon style="display:none">' + data.to_s.gsub('=>', ' : ') +
16
+ '</gon>'
16
17
  end
17
18
  end
18
19
 
data/lib/gon/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Gon
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
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.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: