content_tag (modified): Part 1 (app helper)


/ Published in: Ruby
Save to your folder(s)



Copy this code and paste it in your HTML
  1. def content_tag(name, *options, &proc)
  2. content = options.shift unless options.first.is_a?(Hash)
  3. content ||= nil
  4. options = options.shift
  5. if block_given?
  6. concat("<#{name}#{tag_options(options.stringify_keys) if options}>", proc.binding)
  7. yield(content)
  8. concat("</#{name}>", proc.binding)
  9. elsif content.nil?
  10. "<#{name}#{tag_options(options.stringify_keys) if options} />"
  11. else
  12. super(name, content, options)
  13. end
  14. end

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.