No commit activity in last 3 years
No release in over 3 years
Read-out (rails generated) microdata from javascript
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies
 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):

<head>
  ..
  <%= microdata_fu %>
  ..
</head>

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 © 2008-2010 Wolfger Schramm <wolfger@spearwolf.de>, released under the MIT license