https://github.com/spearwolf/microdata_fu
Passing microdata from rails to javascript
https://github.com/spearwolf/microdata_fu
Last synced: 10 months ago
JSON representation
Passing microdata from rails to javascript
- Host: GitHub
- URL: https://github.com/spearwolf/microdata_fu
- Owner: spearwolf
- License: mit
- Created: 2009-02-19T14:56:19.000Z (over 17 years ago)
- Default Branch: master
- Last Pushed: 2010-03-23T08:50:28.000Z (about 16 years ago)
- Last Synced: 2025-07-28T03:44:55.956Z (11 months ago)
- Language: Ruby
- Homepage:
- Size: 109 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rdoc
- License: MIT-LICENSE
Awesome Lists containing this project
README
= microdata_fu (rails plugin)
A simple rails plugin which enables you to..
- store non-visible data (microdata) into your html
- read-out the data from javascript
== How to Install
First, add microdata_fu to your list of gems in config/environment.rb:
config.gem 'spearwolf-microdata_fu', :lib => 'microdata_fu', :source => 'http://gems.github.com'
Then insert into your html layout the microdata_fu tag (e.g. app/views/layouts/application.html.erb):
..
<%= microdata_fu %>
..
== Usage Example
=== Define microdata in your controller
class MyController << ApplicationController
def index
microdata :foo, 'foo'
microdata :bar, { :abc => 'ABC', :xyz => 123 }
microdata :user, User.find(params[:id])
end
end
=== Set microdata storage type
microdata :foo, 'bar' # by default values are stored in controller instance
microdata :plah, 'foo', :flash => true # use rails flash storage
microdata :bar, 'plah!', :session => true # use session storage
=== Read-out microdata from javascript
In javascript you can read-out the microdata through the microdata_fu api:
var foo = microdata_fu.read('foo');
or use the optional callback function:
mircodata_fu.read('bar', function(bar) {
/* ...do whatever you want with bar here...
if bar is undefined this callback won't be executed */
});
== Author
Copyright (c) 2008-2010 Wolfger Schramm , released under the MIT license