Class: Mullet::HTML::Element

Inherits:
Object
  • Object
show all
Defined in:
lib/mullet/html/element.rb

Overview

HTML element

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(qualified_name, attributes) ⇒ Element

Constructor

Parameters:

  • qualified_name (String)

    tag name with namespace prefix

  • attributes (Attributes)

    attributes from template



21
22
23
24
25
26
# File 'lib/mullet/html/element.rb', line 21

def initialize(qualified_name, attributes)
  @name = qualified_name
  @attributes = attributes
  @has_content = false
  @has_command = false
end

Instance Attribute Details

#attributesObject (readonly)

attributes from template



7
8
9
# File 'lib/mullet/html/element.rb', line 7

def attributes
  @attributes
end

#has_commandObject

true if element has any template command



13
14
15
# File 'lib/mullet/html/element.rb', line 13

def has_command
  @has_command
end

#has_contentObject

true if element has any child element or text content



10
11
12
# File 'lib/mullet/html/element.rb', line 10

def has_content
  @has_content
end

Instance Method Details

#render_end_tagObject



36
37
38
# File 'lib/mullet/html/element.rb', line 36

def render_end_tag()
  return "</#{@name}>"
end

#render_start_tag(attributes) ⇒ Object

Renders start tag

Parameters:

  • attributes (Attributes)

    attributes to render



32
33
34
# File 'lib/mullet/html/element.rb', line 32

def render_start_tag(attributes)
  return "<#{@name}#{attributes.render()}>"
end