Helper for page titles and descriptions
module ApplicationHelper
# Helper to display titles and descriptions.
# Used in views and the layout.
#
# in a layout file:
#
# <title><%= page :title %></title>
# <meta name="description" value="<%= page :description %>" />
#
# and in a view file:
#
# <% page :title, "Awesome Title!" %>
# <% page :description, "Meta Description of the Gods." %>
#
def page(sym, t = nil)
return content_for(sym) { t } unless t.nil?
content_for?(sym) ? content_for(sym) : "Untitled"
end
end
Written by Kyle Meyer
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#