Method: Padrino::Helpers::TagHelpers#content_tag
- Defined in:
- padrino-helpers/lib/padrino-helpers/tag_helpers.rb
#content_tag(name, content, options = nil) ⇒ String #content_tag(name, options = nil, &block) ⇒ String
Creates an HTML tag with given name, content, and options.
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'padrino-helpers/lib/padrino-helpers/tag_helpers.rb', line 119 def content_tag(name, content = nil, = nil, &block) if block_given? = content if content.is_a?(Hash) content = capture_html(&block) end = (name, ) attributes = tag_attributes() output = SafeBuffer.new output.safe_concat "<#{name}#{attributes}>" if content.respond_to?(:each) && !content.is_a?(String) content.each{ |item| output.concat item; output.safe_concat NEWLINE } else output.concat content.to_s end output.safe_concat "</#{name}>" block_is_template?(block) ? concat_content(output) : output end |