/ Published in: Ruby
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
def content_tag(name, *options, &proc) content = options.shift unless options.first.is_a?(Hash) content ||= nil options = options.shift if block_given? concat("<#{name}#{tag_options(options.stringify_keys) if options}>", proc.binding) yield(content) concat("</#{name}>", proc.binding) elsif content.nil? "<#{name}#{tag_options(options.stringify_keys) if options} />" else super(name, content, options) end end