Class: Xomponent::Document

Inherits:
Object
  • Object
show all
Defined in:
lib/Xomponent/Document.rb

Constant Summary collapse

DOCTYPE =
'<!DOCTYPE html>'

Instance Attribute Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, **args, &block) ⇒ Object



8
9
10
# File 'lib/Xomponent/Document.rb', line 8

def method_missing(name, **args, &block)
  Element.new(name, args, &block)
end

Instance Attribute Details

#head_inner=(value) ⇒ Object (writeonly)

Sets the attribute head_inner

Parameters:

  • value

    the value to set the attribute head_inner to.



5
6
7
# File 'lib/Xomponent/Document.rb', line 5

def head_inner=(value)
  @head_inner = value
end

#script_content=(value) ⇒ Object (writeonly)

Sets the attribute script_content

Parameters:

  • value

    the value to set the attribute script_content to.



5
6
7
# File 'lib/Xomponent/Document.rb', line 5

def script_content=(value)
  @script_content = value
end

#style_content=(value) ⇒ Object (writeonly)

Sets the attribute style_content

Parameters:

  • value

    the value to set the attribute style_content to.



5
6
7
# File 'lib/Xomponent/Document.rb', line 5

def style_content=(value)
  @style_content = value
end

#title_content=(value) ⇒ Object (writeonly)

Sets the attribute title_content

Parameters:

  • value

    the value to set the attribute title_content to.



5
6
7
# File 'lib/Xomponent/Document.rb', line 5

def title_content=(value)
  @title_content = value
end

Instance Method Details

#head_contentObject



12
13
14
15
# File 'lib/Xomponent/Document.rb', line 12

def head_content
  title { @title_content } +
  style { @style_content } + (@head_inner || '')
end

#renderObject



17
18
19
20
21
22
23
24
25
# File 'lib/Xomponent/Document.rb', line 17

def render
  DOCTYPE + html {
    head { head_content } +
    body {
      div(id: :app) +
      script { @script_content }
    }
  }
end