Class: Eskimo::HTML::Builder

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

Class Method Summary collapse

Class Method Details

.method_missing(method, *params, &block) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/eskimo/html/builder.rb', line 6

def self.method_missing(method, *params, &block)
  return super unless Eskimo::HTML.valid_tagname?(method.to_s)

  attrs, children = case params.count
  when 0
    [nil, nil]
  when 1
    if params[0].is_a?(Hash)
      [attrs, nil]
    else
      [nil, Proc.new { params[0] }]
    end
  when 2
    [params[0], Proc.new { params[1] }]
  end

  Eskimo::HTML::Component.tag(method.to_s, attrs, &children)
end