README.md in gon-5.2.3 vs README.md in gon-6.0.0

- old
+ new

@@ -1,11 +1,12 @@ # Gon gem — get your Rails variables in your js +[![Join the chat at https://gitter.im/gazay/gon](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/gazay/gon?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) + ![Gon. You should try this. If you look closer - you will see an elephant.](https://github.com/gazay/gon/raw/master/doc/logo_small.png) -[![Build Status](https://secure.travis-ci.org/gazay/gon.png)](http://travis-ci.org/gazay/gon) [![CodeClimate](https://codeclimate.com/github/gazay/gon.png)](https://codeclimate.com/github/gazay/gon) -[![gon API Documentation](https://www.omniref.com/ruby/gems/gon.png)](https://www.omniref.com/ruby/gems/gon) +[![Build Status](https://secure.travis-ci.org/gazay/gon.png)](http://travis-ci.org/gazay/gon) [![CodeClimate](https://codeclimate.com/github/gazay/gon/badges/gpa.svg)](https://codeclimate.com/github/gazay/gon) If you need to send some data to your js files and you don't want to do this with long way through views and parsing - use this force! Now you can easily renew data in your variables through ajax with [gon.watch](https://github.com/gazay/gon/wiki/Usage-gon-watch)! @@ -13,10 +14,14 @@ For Sinatra available [gon-sinatra](https://github.com/gazay/gon-sinatra). For .Net MVC available port [NGon](https://github.com/brooklynDev/NGon). +<a href="https://evilmartians.com/?utm_source=gon"> +<img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg" alt="Sponsored by Evil Martians" width="236" height="54"> +</a> + ## An example of typical use ### Very good and detailed example and reasons to use is considered in [railscast](http://railscasts.com/episodes/324-passing-data-to-javascript) by Ryan Bates When you need to send some start data from your controller to your js @@ -66,23 +71,28 @@ ## Usage ### More details about configuration and usage you can find in [gon wiki](https://github.com/gazay/gon/wiki) -Old readme available in [./README_old.md](https://github.com/gazay/gon/blob/master/README_old.md) - - `app/views/layouts/application.html.erb` ``` erb <head> <title>some title</title> <%= include_gon %> <!-- include your action js code --> ... ``` +For rails 4: +``` erb + <%= Gon::Base.render_data %> + ... +``` + + + You can pass some [options](https://github.com/gazay/gon/wiki/Options) to `include_gon` method. You put something like this in the action of your controller: @@ -111,14 +121,14 @@ alert(gon.your_hash) ``` ### AMD compatible version: `include_gon_amd` -If your site uses AMD modules you can use the `include_gon_amd` helper to -include the variables and watch function as a module. Options are mostly -the same as for `include_gon`, except for `namespace_check`, which does -nothing and `namespace`, which is used as the name of the defined module. +If your site uses AMD modules you can use the `include_gon_amd` helper to +include the variables and watch function as a module. Options are mostly +the same as for `include_gon`, except for `namespace_check`, which does +nothing and `namespace`, which is used as the name of the defined module. The end result will look somewhat like the following: ```js define('yourNameSpace', [], function() { var gon = {}; @@ -216,9 +226,10 @@ Gon uses `MultiJson` with autodetect mode, so all you need is just require your JSON library. ## Contributors * @gazay +* @takiy33 Special thanks to @brainopia, @kossnocorp and @ai. ## License