Created
June 21, 2010 16:11
-
-
Save coryschires/447079 to your computer and use it in GitHub Desktop.
layout helper methods
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 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