module BBLib::HTML::Builder

Public Class Methods

build(type = nil, content = nil, **attributes, &block) click to toggle source
# 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

Public Instance Methods

build(&block) click to toggle source
# File lib/bblib/html/builder.rb, line 27
def build(&block)
  instance_eval(&block)
  self
end