Module: HierarchicalPageTitles::ControllerHelpers
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/hierarchical_page_titles/controller_helpers.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#page_title!(title) ⇒ Object
(also: #set_page_title, #page_title)
Public: Set the page title for a single action.
-
#page_title? ⇒ Boolean
Public: Determine whether there is a page title to display.
-
#page_title_set? ⇒ Boolean
Public: Determine whether the page title has been set yet.
-
#title!(*titles) ⇒ Object
(also: #set_window_and_page_title, #title)
Public: Add to the window titles and set the page title at the same time.
-
#window_title!(*titles) ⇒ Object
(also: #add_to_window_title, #window_title)
Public: Append a string to the list of window titles on a per-action basis.
-
#window_title? ⇒ Boolean
Public: Determine whether there are any window titles to display.
-
#window_title_set? ⇒ Boolean
Public: Determine whether any window titles have been set yet.
-
#window_titles ⇒ Object
Public: Return the current array of window titles.
Instance Method Details
#page_title!(title) ⇒ Object Also known as: set_page_title, page_title
Public: Set the page title for a single action.
Note: This is really only here for use in a before_filter. If you wish to set the window title for a single action you should do so on the view level.
title - A String.
Returns the current page title.
127 128 129 |
# File 'lib/hierarchical_page_titles/controller_helpers.rb', line 127 def page_title!(title) @_page_title = title end |
#page_title? ⇒ Boolean
Public: Determine whether there is a page title to display.
Returns true or false.
148 149 150 |
# File 'lib/hierarchical_page_titles/controller_helpers.rb', line 148 def page_title? @_page_title.present? end |
#page_title_set? ⇒ Boolean
Public: Determine whether the page title has been set yet.
Returns true or false.
156 157 158 |
# File 'lib/hierarchical_page_titles/controller_helpers.rb', line 156 def page_title_set? defined?(@_page_title) end |
#title!(*titles) ⇒ Object Also known as: set_window_and_page_title, title
Public: Add to the window titles and set the page title at the same time.
Note: This is really only here for use in a before_filter. If you wish to set the window title for a single action you should do so on the view level.
*titles - An Array of Strings. The whole Array will be appended to the
window titles; the last item in the Array will be used as the
page title.
Returns nothing.
172 173 174 175 |
# File 'lib/hierarchical_page_titles/controller_helpers.rb', line 172 def title!(*titles) window_title!(*titles) page_title!(titles.last) end |
#window_title!(*titles) ⇒ Object Also known as: add_to_window_title, window_title
Public: Append a string to the list of window titles on a per-action basis.
Note: This is really only here for use in a before_filter. If you wish to set the window title for a single action you should do so on the view level.
*titles - An Array of Strings which will be appended to the window titles.
Example:
class FoosController < ApplicationController
def index
window_title! 'Foos'
end
def new
end
end
# foos/index.html.erb
<%= window_title %>
<%# => 'Foos' %>
# foos/new.html.erb
<%= window_title %>
<%# => "" %>
Returns the current Array of window titles.
88 89 90 91 |
# File 'lib/hierarchical_page_titles/controller_helpers.rb', line 88 def window_title!(*titles) @_window_titles ||= [] @_window_titles.concat titles.flatten end |
#window_title? ⇒ Boolean
Public: Determine whether there are any window titles to display.
Returns true or false.
105 106 107 |
# File 'lib/hierarchical_page_titles/controller_helpers.rb', line 105 def window_title? window_title_set? and @_window_titles.any? end |
#window_title_set? ⇒ Boolean
Public: Determine whether any window titles have been set yet.
Returns true or false.
113 114 115 |
# File 'lib/hierarchical_page_titles/controller_helpers.rb', line 113 def window_title_set? defined?(@_window_titles) end |
#window_titles ⇒ Object
Public: Return the current array of window titles.
97 98 99 |
# File 'lib/hierarchical_page_titles/controller_helpers.rb', line 97 def window_titles @_window_titles end |