Skip to content

Instantly share code, notes, and snippets.

@farski
Created May 10, 2011 14:10
Show Gist options
  • Save farski/964536 to your computer and use it in GitHub Desktop.
Save farski/964536 to your computer and use it in GitHub Desktop.
# In erb view
<% title('Title text') # as helper %>
<%= content_for :title %>
<% content_for(:subtitle) { 'Subtitle text' } %>
<%= content_for :subtitle %>
<% content_for(:copy) { 'Copy text' } %>
<%= yield :copy %>
# Result
Title text
Subtitle text
Copy text
# In haml view
- title('Title text')
= content_for(:title)
- content_for(:subtitle) { 'Subtitle text' }
= content_for(:subtitle)
- content_for(:copy) { 'Subtitle text' }
= content_for(:copy)
# Result
Title text
# content_for setting is not working outside of helpers...
# content_for?(:subtitle) returns false, so there's something preventing this stuff from being set.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment