Skip to content

Instantly share code, notes, and snippets.

@mdarby
Created January 4, 2009 16:07
Show Gist options
  • Save mdarby/43084 to your computer and use it in GitHub Desktop.
Save mdarby/43084 to your computer and use it in GitHub Desktop.
# application_helper.rb
# Generic form label styling
def box_label(text)
text = "#{text}:" unless text.end_with?(":")
"<span class=\"box_label\">#{text}</span>"
end
# A generic box to encapsulate some text
def box(title = nil, *args, &block)
options = args.extract_options!
style = options[:style] ? " style = '#{options[:style]}'" : ''
b = "<div class=\"box\"#{style}>#{box_label(title) if title}"
e = '</div>'
data = capture(&block)
res = b + data + e
concat(res, block.binding)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment