module Snipp::Markup::Microdata

Public Instance Methods

breadcrumb(paths, options = {}) click to toggle source
geo(latitude, longitude, options = {}) click to toggle source
# File lib/snipp/markups/microdata.rb, line 36
def geo latitude, longitude, options = {}
  return unless latitude and longitude
  item_tag :span, prop: :geo, scope: true, type: :geo, class: "geo" do
    "#{item_tag :meta, nil, prop: :latitude, content: latitude}#{item_tag :meta, nil, prop: :longitude, content: longitude}".html_safe
  end
end
item_options(options, escape = true) click to toggle source
# File lib/snipp/markups/microdata.rb, line 60
def item_options options, escape = true
  attrs = ''
  attrs << " itemprop=\"#{escape ? ERB::Util.h(options.delete :prop) : options.delete(:prop)}\"" if options.key? :prop
  attrs << " itemscope" if options.delete :scope
  attrs << " itemtype=\"http://data-vocabulary.org/#{options.delete(:type).to_s.camelize}\"" if options.key? :type
  attrs.html_safe
end
item_tag(name, content_or_options_with_block = nil, options = nil, escape = true, &block) click to toggle source
# File lib/snipp/markups/microdata.rb, line 43
def item_tag name, content_or_options_with_block = nil, options = nil, escape = true, &block
  if block_given?
    options = content_or_options_with_block if content_or_options_with_block.is_a?(Hash)
    content = capture(&block)
  else
    content = content_or_options_with_block
  end
  item_options = item_options options, escape if options
  tag_options  = tag_options  options, escape if options
  content = if block_given? then capture(&block) else content_or_options_with_block end
  if content
    "<#{name}#{tag_options}#{item_options}>#{escape ? ERB::Util.h(content) : content}</#{name}>".html_safe
  else
    "<#{name}#{tag_options}#{item_options} />".html_safe
  end
end