Created
January 14, 2011 22:51
-
-
Save scottillogical/780446 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
# application.html.erb | |
<%=raw yield_section(1, :description) %> | |
# application_helper.rb | |
def yield_section(number, content_name) | |
content = find_dynamic_content(number) | |
return content if content | |
yield content_name # throws a no block given (yield) error, it's supposed to yield to the view | |
end | |
# show.html.erb | |
<% content_for :description %> | |
DEFAULT CONTENT HERE | |
<% end %> | |
# i could do it like this | |
<% if yield_section(1) %> | |
<div><%= yield_section(1) %></div> | |
<% else %> | |
<div>yield :description</div> | |
<% end %> |
Author
scottillogical
commented
Jan 14, 2011
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment