Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 65 lines (41 sloc) 2.143 kB
89df60b @gazay Initial commit
authored
1 # Gon gem — get your Rails variables in your js
2
020007b @gazay Added description and usage
authored
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!
89df60b @gazay Initial commit
authored
4
5 ## Usage
6
020007b @gazay Added description and usage
authored
7 `app/views/layouts/application.html.erb`
8
9 ``` erb
10 <head>
11 <title>some title</title>
83b22e3 @gazay Js generation
authored
12 <%= include_gon %>
13 <!-- include your action js code -->
020007b @gazay Added description and usage
authored
14 ...
15 ```
16
17 In action of your controller you put something like this:
18
19 ``` ruby
20 @your_variable = 123
21 Gon.your_variable = @your_variable
22 Gon.your_other_variable = 345 + @your_variable
23 ```
24
25 In javascript file for view of this action write call to your variable:
26
27 ``` js
28 alert(Gon.your_variable)
29 alert(Gon.your_other_variable)
30 ```
89df60b @gazay Initial commit
authored
31
32 ## Installation
33
34 Puts this line into `Gemfile` then run `$ bundle`:
35
36 ``` ruby
c0c0548 @gazay Changed version in readme
authored
37 gem 'gon', '0.2.0'
89df60b @gazay Initial commit
authored
38 ```
39
40 Or if you are old-school Rails 2 developer put this into `config/environment.rb` and run `$ rake gems:install`:
41
42 ``` ruby
c0c0548 @gazay Changed version in readme
authored
43 config.gem 'gon', :version => '0.2.0'
89df60b @gazay Initial commit
authored
44 ```
45
da310ad @gazay Edited README.md via GitHub
authored
46 Or manually install gon gem: `$ gem install gon`
89df60b @gazay Initial commit
authored
47
48 ## Contributors
49
50 * @gazay
51
2f1bc0e @gazay Edited README.md via GitHub
authored
52 Special thanks to @brainopia, @kossnocorp and @ai.
89df60b @gazay Initial commit
authored
53
54 ## License
55
56 The MIT License
57
58 Copyright (c) 2011 gazay
59
60 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
61
62 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
63
64 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Something went wrong with that request. Please try again.