# Green Monkey ## About This Gem allows you to make html-layout with microdata properties easier. It works with ruby 1.9, rails 3, haml 3. ![Green Monkey](http://upload.wikimedia.org/wikipedia/commons/thumb/b/b1/Bijilo-Portrait-of-a-Callithrix-Monkey.jpg/320px-Bijilo-Portrait-of-a-Callithrix-Monkey.jpg) ## Install Add to Gemfile ```ruby gem "green_monkey" ``` ## Examples ### helper `time_tag` It almost as rails' time_tag but make `datetime` attribute in iso8601 format, according to Microdata specifications Also it accepts Numeric values as duration Haml & HTML: ```haml = time_tag post.created_at = time_tag post.created_at, itemprop: "datePublished" = time_tag 3.hours + 30.minutes ``` ```html ``` ### helper `time_tag_interval` The same with `time_tag` but made for time intervals ```haml = time_tag_interval Time.parse("14 March 1879"), Time.parse("18 April 1955"), :format => '%d %h %Y' = time_tag_interval Time.parse("14 March 1989"), 150.hours, :format => :short ``` ```html ``` ### ActiveRecord::Base#html\_schema\_type ```ruby class User < ActiveRecord::Base html_schema_type :Person end User.html_schema_type #=> Mida::SchemaOrg::Person User.find(1).html_schema_type => Mida::SchemaOrg::Person ``` ### Haml magic Attribute `itemprop` ```haml %span[:name]= item.name Item name ``` `itemscope` and `iteptype` attributes ```haml %article[Mida(:Event)] # =>
%article[Mida(:Event, :DrinkUp)] # =>
%article[@user] # =>
``` ### Real examples Haml: ```haml %article[post] = link_to "/posts/#{post.id}", :itemprop => "url" do %h3[:name]>= post.title .post_body[:articleBody]= post.body.html_safe = time_tag(post.created_at, :itemprop => "datePublished") ``` Output: ```html
Some text
``` Haml: ```haml %article[project] %header = link_to project.url, itemprop: 'url', target: "_blank" do %h3[:name]<>= project.title = " " - if project.source_code.present? = link_to "(source code)", project.source_code, class: "source_link", target: "_blank" %section[:description] = simple_format project.description %ul - for item_type in project.item_types.split(" ") %li[Mida(:WebPageElement, :ItemType), :mentions] %span[:name]= item_type ``` Output: ```html
(source code)

A Ruby Microdata parser/extractor

``` -------- I use it in [Microdata tools](http://github.com/paxa/semantic_data/ "my own project")