def _insert(*args, &blk)
raise Error, "This tag is already closed" if @_done
if !args.empty? && !args[0].is_a?(Hash)
content = args.shift
raise Error, "Tag doesn't allow content" if @_has_content == false
@_has_content = true
end
if content
@_content = CGI.escapeHTML(content.to_s)
@_done = true
end
if !args.empty?
_merge_attributes(*args)
@_done = true
end
if block_given?
raise Error, "Tag doesn't allow content" if @_has_content == false
@_has_content = true
@_block = blk
@_done = true
end
if @_content && @_block
raise Error, "Both content and _block is not allowed"
end
@_instance.mab_done(self) if @_done
if @_block
before = @_context.children
res = @_block.call
if before >= @_context.children
@_content = res.to_s
else
@_has_content = false
@_instance.mab_insert("</#{@_name}>")
end
end
self
end