Permalink
Browse files

Added description and usage

  • Loading branch information...
1 parent 89df60b commit 020007b40fa9a96dbe4225f99ef5b315b324bfd8 @gazay committed May 9, 2011
Showing with 27 additions and 3 deletions.
  1. +26 −2 README.md
  2. +1 −1 gon.gemspec
View
28 README.md
@@ -1,10 +1,34 @@
# Gon gem — get your Rails variables in your js
-TODO: write description
+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!
## Usage
-TODO: write usage
+`app/views/layouts/application.html.erb`
+
+``` erb
+<head>
+ <title>some title</title>
+ <gon style='display:none'><%= gon_variables %></gon>
+ <%= javascript_include_tag 'http://code.jquery.com/jquery-1.6.min.js' %> <!-- include jquery -->
+ <%= include_gon %>
+ ...
+```
+
+In action of your controller you put something like this:
+
+``` ruby
+@your_variable = 123
+Gon.your_variable = @your_variable
+Gon.your_other_variable = 345 + @your_variable
+```
+
+In javascript file for view of this action write call to your variable:
+
+``` js
+alert(Gon.your_variable)
+alert(Gon.your_other_variable)
+```
## Installation
View
2 gon.gemspec
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
s.summary = %q{Get your Rails variables in your JS}
s.description = %q{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!}
- # s.rubyforge_project = "gem"
+ s.rubyforge_project = "gon"
s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")

0 comments on commit 020007b

Please sign in to comment.