Skip to content

Instantly share code, notes, and snippets.

@coryschires
Created June 21, 2010 16:11
Show Gist options
  • Select an option

  • Save coryschires/447079 to your computer and use it in GitHub Desktop.

Select an option

Save coryschires/447079 to your computer and use it in GitHub Desktop.
layout helper methods
module LayoutHelper
def title(page_title, show_title = true)
content_for(:title) { page_title.to_s }
@show_title = show_title
end
def show_title?
@show_title
end
def subtitle(subtitle)
content_for(:subtitle) { subtitle }
@subtitle = subtitle
end
def show_subtitle?
@subtitle
end
def include_navigation?
current_page = "#{controller.controller_name} #{controller.action_name}"
pages_requiring_nav = [ "events show"]
pages_requiring_nav.include?(current_page)
end
def stylesheet(*args)
content_for(:head) { stylesheet_link_tag(*args.map(&:to_s)) }
end
def javascript(*args)
args = args.map { |arg| arg == :defaults ? arg : arg.to_s }
content_for(:head) { javascript_include_tag(*args) }
end
def html5(hotlink_url)
raw("<!--[if IE]><script src='#{hotlink_url}'></script><![endif]-->")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment