Sha256: 7ab25c1ccb8d8e0ab353b02e1501d4031d32f7b84c5a4735e2039b458a1280fc

Contents?: true

Size: 1 KB

Versions: 16

Compression:

Stored size: 1 KB

Contents

# -*- encoding: utf-8 -*-
require 'cgi'

module Webgen
  class Tag

    # Provides easy access to the meta information of a node.
    module MetaInfo

      # Treat +tag+ as a meta information key and return its value from the content node.
      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

    end

  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
webgen-1.7.3 lib/webgen/tag/meta_info.rb
webgen-1.7.2 lib/webgen/tag/meta_info.rb
webgen-1.7.1 lib/webgen/tag/meta_info.rb
webgen-1.7.0 lib/webgen/tag/meta_info.rb
webgen-1.6.0 lib/webgen/tag/meta_info.rb
webgen-1.5.2 lib/webgen/tag/meta_info.rb
webgen-1.5.1 lib/webgen/tag/meta_info.rb
webgen-1.5.0 lib/webgen/tag/meta_info.rb
webgen-1.4.1 lib/webgen/tag/meta_info.rb
webgen-1.4.0 lib/webgen/tag/meta_info.rb
webgen-1.3.0 lib/webgen/tag/meta_info.rb
webgen-1.2.1 lib/webgen/tag/meta_info.rb
webgen-1.2.0 lib/webgen/tag/meta_info.rb
webgen-1.1.0 lib/webgen/tag/meta_info.rb
webgen-1.0.0 lib/webgen/tag/meta_info.rb
webgen-1.0.0.beta3 lib/webgen/tag/meta_info.rb