Module: Webgen::Tag::MetaInfo

Defined in:
lib/webgen/tag/meta_info.rb

Overview

Provides easy access to the meta information of a node.

Class Method Summary collapse

Class Method Details

.call(tag, body, context) ⇒ Object

Treat tag as a meta information key and return its value from the content node.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/webgen/tag/meta_info.rb', line 11

def self.call(tag, body, context)
  tag = context[:config]['tag.meta_info.mi'] if tag == 'meta_info'
  output = ''
  if tag == 'lang'
    output = context.content_node.lang
  elsif context.content_node[tag]
    output = context.content_node[tag].to_s
    output = CGI::escapeHTML(output) if context[:config]['tag.meta_info.escape_html']
  else
    context.website.logger.error do
      ["No meta info key '#{tag}' found in <#{context.content_node}> (referenced in <#{context.ref_node}>)",
       "Add the meta info key '#{tag}' to <#{context.content_node}> or remove the" +
       " reference in <#{context.ref_node}> to fix this error."]
    end
  end
  output
end