Class: MetaTags::Tag

Inherits:
Object
  • Object
show all
Defined in:
lib/meta_tags-rails/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



11
12
13
14
# File 'lib/meta_tags-rails/tag.rb', line 11

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

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



4
5
6
# File 'lib/meta_tags-rails/tag.rb', line 4

def attributes
  @attributes
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/meta_tags-rails/tag.rb', line 4

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.



21
22
23
# File 'lib/meta_tags-rails/tag.rb', line 21

def render(view)
  view.tag(name, attributes)
end