Posted By

imakethings on 06/27/07


Tagged

rails helpers contenttag


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

webstic


content_tag (modified): Part 1 (app helper)


 / Published in: Ruby
 

  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  

You need to login to post a comment.