Sha256: 4306350f7cc734292bd1b9e3786ead6e49f4ecca5b0eb7289bffedc120994c03

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

class Microformats::Calendar
  include Microformats::FormattingHelpers

  def initialize(template)
    @template = template
    @default_tag = :span
  end

  # You can directly initialize and run this class, but it's easier
  # to use the Microformats::Helpers#vcalendar helper method.
  #
  # OPTIONS:
  # * :tag - The HTML wrapper element (defaults to :div)
  # * Any other passed options will be treated as HTML attributes.
  #
  def run(opts = {}, &block)
    opts[:class] = combine_class_names('vcalendar', opts[:class])
    opts[:tag] ||= :div
    concat_tag(opts) do
      block.call(self)
    end
  end

  # 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:
  #   <% calendar.event :id => 'my_event' do |event| %>
  #     This event is called <%= event.name "Cool Event" %>.
  #   <% end %>
  #
  def event(opts = {}, &block)
    ev = Microformats::Event.new(@template)
    opts[:class] = combine_class_names('vevent', opts[:class])
    ev.run(opts, &block)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
microformats-0.3 lib/calendar.rb