Class: Weby::HTMLBuilder

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

Instance Method Summary collapse

Constructor Details

#initialize(parent) ⇒ HTMLBuilder

Returns a new instance of HTMLBuilder.



523
524
525
# File 'lib/weby/html.rb', line 523

def initialize(parent)
    @parent = parent
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, attrs = {}, &block) ⇒ Object



532
533
534
535
536
537
538
539
540
541
# File 'lib/weby/html.rb', line 532

def method_missing(m, attrs = {}, &block)
    attrs[:_doc] = @parent
    element = HTML.new m, attrs, &block
    if @mode == :prepend
        @parent.prepend element
    else
        @parent.append element
    end
    element
end

Instance Method Details

#mode(mode) ⇒ Object



527
528
529
530
# File 'lib/weby/html.rb', line 527

def mode(mode)
    @mode = mode
    self
end