Created
April 26, 2011 08:42
-
-
Save stammy/941997 to your computer and use it in GitHub Desktop.
rails 3 pretty page titles. no more instance vars all up in your controllers
This file contains hidden or 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
module ApplicationHelper | |
# pretty page titles | |
# yield_for(:title, 'default text goes here') in layout | |
# content_for(:title, 'some text') in view | |
def yield_for(content_sym, default) | |
output = content_for(content_sym) | |
output = default if output.blank? | |
output | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
rails 3 friendly version of ryan bates's pretty page titles from 2007 http://railscasts.com/episodes/30-pretty-page-title