Class: Wee::HtmlDocument
Overview
Represents a complete HTML document.
Constant Summary
Constants inherited
from HtmlWriter
Wee::HtmlWriter::CLOSING, Wee::HtmlWriter::SINGLE_CLOSING
Instance Attribute Summary
Attributes inherited from HtmlWriter
#port
Instance Method Summary
collapse
Methods inherited from HtmlWriter
#encode_text, #end_tag, #single_tag, #start_tag, #text, #write
Constructor Details
Returns a new instance of HtmlDocument.
9
10
11
|
# File 'lib/wee/html_document.rb', line 9
def initialize
super([])
end
|
Instance Method Details
#define_divert(tag) ⇒ Object
21
22
23
24
25
|
# File 'lib/wee/html_document.rb', line 21
def define_divert(tag)
raise ArgumentError if has_divert?(tag)
@divert ||= {}
@port << (@divert[tag] = [])
end
|
#divert(tag, txt = nil, &block) ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/wee/html_document.rb', line 27
def divert(tag, txt=nil, &block)
raise ArgumentError unless has_divert?(tag)
raise ArgumentError if txt and block
divert = @divert[tag]
if txt
divert << txt
end
if block
old_port = @port
begin
@port = divert
block.call
ensure
@port = old_port
end
end
end
|
#has_divert?(tag) ⇒ Boolean
17
18
19
|
# File 'lib/wee/html_document.rb', line 17
def has_divert?(tag)
@divert and @divert[tag]
end
|
13
14
15
|
# File 'lib/wee/html_document.rb', line 13
def set
@set ||= {}
end
|
48
49
50
|
# File 'lib/wee/html_document.rb', line 48
def to_s
@port.join
end
|