private Method

Element.tag(indent, additional_attrs={}, &block)

There's no documentation for this item.

Source Code

# File rss/rss.rb, line 674
def tag(indent, additional_attrs={}, &block)
  next_indent = indent + INDENT

  attrs = collect_attrs
  return "" if attrs.nil?

  attrs.update(additional_attrs)
  start_tag = make_start_tag(indent, next_indent, attrs)

  if block
    content = block.call(next_indent)
  else
    content = []
  end

  if content.is_a?(String)
    content = [content]
    start_tag << ">"
    end_tag = "</#{full_name}>"
  else
    content = content.reject{|x| x.empty?}
    if content.empty?
      end_tag = "/>"
    else
      start_tag << ">\n"
      end_tag = "\n#{indent}</#{full_name}>"
    end
  end

  start_tag + content.join("\n") + end_tag
end
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.