Method: AnyView::Helpers::TagHelpers#tag
- Defined in:
- lib/any_view/tag_helpers.rb
#tag(name, options = {}) ⇒ Object
Creates an html tag with the given name and options
31 32 33 34 35 36 37 |
# File 'lib/any_view/tag_helpers.rb', line 31 def tag(name, ={}) content, open_tag = .delete(:content), .delete(:open) identity_tag_attributes.each { |attr| [attr] = attr.to_s if [attr] } html_attrs = .collect { |a, v| v.blank? ? nil : "#{a}=\"#{v}\"" }.compact.join(" ") base_tag = (!html_attrs.blank? ? "<#{name} #{html_attrs}" : "<#{name}") base_tag << (open_tag ? ">" : (content ? ">#{content}</#{name}>" : " />")) end |