Sha256: 386efeb23ea8e5a9367ded7abf25e26e214c47024e025575d55710b64afd3e99

Contents?: true

Size: 824 Bytes

Versions: 1

Compression:

Stored size: 824 Bytes

Contents

module MetaTags
  # Represents an HTML meta tag with no content (<tag />).
  class Tag
    attr_reader :name, :attributes

    # Initializes a new instance of Tag class.
    #
    # @param [String, Symbol] name HTML tag name
    # @param [Hash] attributes list of HTML tag attributes
    #
    def initialize(name, attributes = {})
      @name = name
      @attributes = attributes
    end

    # Render tag into a Rails view.
    #
    # @param [ActionView::Base] view instance of a Rails view.
    # @return [String] HTML string for the tag.
    #
    def render(view)
      view.tag(name, prepare_attributes(attributes))
    end

    protected

    def prepare_attributes(attributes)
      attributes.each do |key, value|
        attributes[key] = value.iso8601 if value.respond_to?(:iso8601)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
meta-tags-2.6.0 lib/meta_tags/tag.rb