Skip to content

Instantly share code, notes, and snippets.

@nicolasblanco
Created May 5, 2010 09:51
Show Gist options
  • Save nicolasblanco/390584 to your computer and use it in GitHub Desktop.
Save nicolasblanco/390584 to your computer and use it in GitHub Desktop.
def p_cool(text=nil, options={}, &proc)
raise ArgumentError, "Missing block or text" unless block_given? or text
if block_given?
concat(p_cool(capture(&proc), options))
else
content_tag("p", text, options.merge(:class => "my_cool_class"))
end
end
# In the view :
#
#
# != p_cool "lalala"
#
# - p_cool do
# %strong lalala
#
#
# Outputs :
#
# <p class="my_cool_class">lalala</p>
# <p class="my_cool_class"><strong>lalalala</strong></p>
#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment