Skip to content

Instantly share code, notes, and snippets.

@bunnymatic
Created December 6, 2012 08:28
Show Gist options
  • Save bunnymatic/4222736 to your computer and use it in GitHub Desktop.
Save bunnymatic/4222736 to your computer and use it in GitHub Desktop.
nested content in rails view helpers
# because i can never remember exactly how and when to use concat
# when building content in helpers
def nested_content
content_tag 'div' do
concat(content_tag 'span', 'span block')
concat(tag 'br')
concat(link_to 'root link', root_path)
concat(tag 'br')
concat(link_to('#') do
concat(content_tag 'h2', 'Head \'em off')
concat(tag 'br')
content_tag 'div', (content_tag 'span',(concat 'dudue'))
end)
end
end
@loveybot
Copy link

loveybot commented Dec 6, 2012

Yay Ruby!!

@doshea
Copy link

doshea commented Dec 12, 2015

I didn't even know you could nest blocks inside a method's arguments. Nice work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment