Class: Navigator::Tag

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

Overview

Renders a HTML tag.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, content = nil, attributes: {}, activator: Navigator::TagActivator.new) ⇒ Tag

Returns a new instance of Tag.



6
7
8
9
10
11
# File 'lib/navigator/tag.rb', line 6

def initialize name, content = nil, attributes: {}, activator: Navigator::TagActivator.new
  @name = name
  @content = content
  @attributes = attributes.with_indifferent_access
  @activator = activator
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



4
5
6
# File 'lib/navigator/tag.rb', line 4

def content
  @content
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/navigator/tag.rb', line 4

def name
  @name
end

Instance Method Details

#prefixObject



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

def prefix
  ["<#{name}", format_attributes, '>'].compact * ''
end

#renderObject



21
22
23
# File 'lib/navigator/tag.rb', line 21

def render
  [prefix, content, suffix].compact * ''
end

#suffixObject



17
18
19
# File 'lib/navigator/tag.rb', line 17

def suffix
  "</#{name}>"
end