Module: Metag::Tag

Defined in:
lib/metag/tag.rb

Instance Method Summary collapse

Instance Method Details

#meta_tag(*args) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/metag/tag.rb', line 3

def meta_tag(*args)
  # Handle options
  options = args.pop if args.last.is_a?(Hash)
  options = (options || {}).reverse_merge(separator: ':')

  # Ensure the presence of at least 2 args (property & content)
  if (size = args.size) < 2
    raise ArgumentError, "wrong number of arguments(#{size} for 2)"
  end

  # Meta tag attributes
  attrs = {}
  attrs[:content] = args.pop
  attrs[:property] = args.map(&:to_s).join(options[:separator])

  tag :meta, attrs
end