Microformat helper for Ruby on Rails

microformat-for-rails.png

1. Start here, it’s a great introduction to microformats. Of head over to microformats.org.

2. Install the microformats helper plugin:

./script/plugin install http://labnotes.org/svn/public/ruby/rails_plugins/microformat_helper

3. Include the helper in your controller:

helper :microformat

4. Try it out with an hAtom feed:

<% render_hfeed do
  posts.each do |post|
    render_hentry "post-#{post.id}" do %>
      <%= hentry_title post.title %>
      <%= hentry_content post.content %>
      <p>Published on <%= post.created_on.microformat :published %> by
        <%= hcard :fn=>post.author, :url=>post.author_url, :class=>"author" %>
      </p><%
    end
  end
end %>

The plugin currently provides helper methods for hAtom, basic hCard, and the datetime design pattern.

3 thoughts on “Microformat helper for Ruby on Rails

  1. Pingback: Labnotes » scrAPI 1.2.0: Explicit skip and hAtom

  2. Pingback: MyCATS :: Blog Archive » The Artist Formerly Known as “Learning Object”

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>