Class: PageMeta::HashMetaTag

Inherits:
MetaTag
  • Object
show all
Defined in:
lib/page_meta/hash_meta_tag.rb

Direct Known Subclasses

MetaTag::Og, MetaTag::Twitter

Instance Attribute Summary

Attributes inherited from MetaTag

#name

Instance Method Summary collapse

Methods inherited from MetaTag

build, #content, #helpers, #initialize

Constructor Details

This class inherits a constructor from PageMeta::MetaTag

Instance Method Details

#renderObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/page_meta/hash_meta_tag.rb', line 5

def render
  return if content.empty?

  content.each_with_object([]) do |(attr, value), buffer|
    value = value.call if value.respond_to?(:call)
    value = value.to_s

    next if value.blank?

    attr = attr.to_s.tr("_", ":")

    buffer << helpers.tag(
      :meta,
      property: "#{base_name}:#{attr}",
      content: value
    )
  end.join
end