Class: MetaTags::Tag

Inherits:
Object
  • Object
show all
Defined in:
lib/meta_tags/tag.rb

Overview

Represents an HTML meta tag with no content (<tag />).

Direct Known Subclasses

ContentTag

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, attributes = {}) ⇒ Tag

Initializes a new instance of Tag class.

Parameters:

  • name (String, Symbol)

    HTML tag name

  • attributes (Hash) (defaults to: {})

    list of HTML tag attributes



13
14
15
16
# File 'lib/meta_tags/tag.rb', line 13

def initialize(name, attributes = {})
  @name = name.to_s
  @attributes = attributes
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



6
7
8
# File 'lib/meta_tags/tag.rb', line 6

def attributes
  @attributes
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/meta_tags/tag.rb', line 6

def name
  @name
end

Instance Method Details

#render(view) ⇒ String

Render tag into a Rails view.

Parameters:

  • view (ActionView::Base)

    instance of a Rails view.

Returns:

  • (String)

    HTML string for the tag.



23
24
25
# File 'lib/meta_tags/tag.rb', line 23

def render(view)
  view.tag(name, prepare_attributes(attributes), MetaTags.config.open_meta_tags?)
end