Module: Microformats::Helpers

Defined in:
lib/helpers.rb

Overview

Include this file into your view layer. For example, in Rails:

module ApplicationHelper
  include Microformats::Helpers
end

Instance Method Summary collapse

Instance Method Details

#vaddress(opts = {}, &block) ⇒ Object

Creates a vAddress with the given options and a block.

OPTIONS:

  • :type - A string that specifies the type of address(‘home’, ‘work’, etc)

  • :tag - The HTML wrapper element (defaults to :div)

  • Any other passed options will be treated as HTML attributes.

EXAMPLE:

<% vaddress :type => 'work', :id => 'my_adr' do |adr| %>
  I live at <%= adr.street "123 Main St" %>.
<% end %>


36
37
38
39
# File 'lib/helpers.rb', line 36

def vaddress(opts = {}, &block)
  address = Microformats::Address.new(self)
  address.run(opts, &block)
end

#vcalendar(opts = {}, &block) ⇒ Object

Creates a vCalendar with the given options and a block.

OPTIONS:

  • :tag - The HTML wrapper element (defaults to :div)

  • Any other passed options will be treated as HTML attributes.

EXAMPLE:

<% vcalendar :id => 'my_cal' do |cal| %>
  <% cal.event :id => 'my_event' do |event| %>
    This event is called <%= event.name "Cool Event" %>.
  <% end %>
<% end %>


70
71
72
73
# File 'lib/helpers.rb', line 70

def vcalendar(opts = {}, &block)
  cal = Microformats::Calendar.new(self)
  cal.run(opts, &block)
end

#vcard(opts = {}, &block) ⇒ Object

Creates a vCard with the given options and a block.

OPTIONS:

  • :tag - The HTML wrapper element (defaults to :div)

  • Any other passed options will be treated as HTML attributes.

EXAMPLE:

<% vcard :id => 'my_vcard' do |card| %>
  Hello, my name is <%= card.name "Chris" %>!
<% end %>


19
20
21
22
# File 'lib/helpers.rb', line 19

def vcard(opts = {}, &block)
  card = Microformats::Vcard.new(self)
  card.run(opts, &block)
end

#vevent(opts = {}, &block) ⇒ Object

Creates a vEvent with the given options and a block.

OPTIONS:

  • :tag - The HTML wrapper element (defaults to :div)

  • Any other passed options will be treated as HTML attributes.

EXAMPLE:

<% vevent :id => 'my_event' do |event| %>
  This event is called <%= event.name "Cool Event" %>.
<% end %>


52
53
54
55
# File 'lib/helpers.rb', line 52

def vevent(opts = {}, &block)
  event = Microformats::Event.new(self)
  event.run(opts, &block)
end