Module: BBLib::HTML::Builder

Included in:
Tag
Defined in:
lib/bblib/html/builder.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.build(type = nil, content = nil, **attributes, &block) ⇒ Object

Raises:

  • (ArgumentError)


32
33
34
35
36
37
38
39
40
# File 'lib/bblib/html/builder.rb', line 32

def self.build(type = nil, content = nil, **attributes, &block)
  raise ArgumentError, "Unknown element type '#{type}'." unless TAGS.include?(type.to_s.downcase) || type == nil
  context = attributes.delete(:context)
  if type
    Tag.new(type: type, attributes: attributes, content: content, context: context, &block)
  else
    TagSet.new(attributes: attributes, context: context, &block)
  end
end

Instance Method Details

#build(&block) ⇒ Object



27
28
29
30
# File 'lib/bblib/html/builder.rb', line 27

def build(&block)
  instance_eval(&block)
  self
end