Class: Wee::Brush::Page

Inherits:
Wee::Brush show all
Defined in:
lib/wee/html_brushes.rb

Constant Summary collapse

HTML_HTML =
'html'.freeze
HTML_HEAD =
'head'.freeze
HTML_TITLE =
'title'.freeze
HTML_BODY =
'body'.freeze

Instance Attribute Summary

Attributes inherited from Wee::Brush

#canvas, #document

Instance Method Summary collapse

Methods inherited from Wee::Brush

#close, nesting?, #setup

Instance Method Details

#title(t) ⇒ Object



718
719
720
721
# File 'lib/wee/html_brushes.rb', line 718

def title(t)
  @title = t
  self
end

#with(text = nil, &block) ⇒ Object



692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
# File 'lib/wee/html_brushes.rb', line 692

def with(text=nil, &block)
  @document.start_tag(HTML_HTML)
  @document.start_tag(HTML_HEAD)

  if @title
    @document.start_tag(HTML_TITLE)
    @document.text(@title)
    @document.end_tag(HTML_TITLE)
  end

  @document.end_tag(HTML_HEAD)
  @document.start_tag(HTML_BODY)

  if text
    raise ArgumentError if block
    @document.text(text)
  else
    @canvas.nest(&block) if block 
  end

  @document.end_tag(HTML_BODY)
  @document.end_tag(HTML_HTML)

  @document = @canvas = nil
end