Created
May 5, 2010 09:51
-
-
Save nicolasblanco/390584 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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