Module: HierarchicalPageTitles::ViewHelpers
- Defined in:
- lib/hierarchical_page_titles/view_helpers.rb
Instance Method Summary collapse
-
#page_title!(title) ⇒ Object
(also: #set_page_title, #page_title)
Public: Set the page title for the view.
-
#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 for the view.
-
#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 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 the view.
title - A String.
Returns the current page title.
64 65 66 |
# File 'lib/hierarchical_page_titles/view_helpers.rb', line 64 def page_title!(title) controller.page_title!(title) end |
#page_title? ⇒ Boolean
Public: Determine whether there is a page title to display.
Returns true or false.
80 81 82 |
# File 'lib/hierarchical_page_titles/view_helpers.rb', line 80 def page_title? controller.page_title? end |
#page_title_set? ⇒ Boolean
Public: Determine whether the page title has been set yet.
Returns true or false.
88 89 90 |
# File 'lib/hierarchical_page_titles/view_helpers.rb', line 88 def page_title_set? controller.page_title_set? 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.
*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.
100 101 102 103 |
# File 'lib/hierarchical_page_titles/view_helpers.rb', line 100 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 for the view.
The window titles array used here is inherited from the controller level, so if you add a window title in the controller and then again in the view then there will be two items in the window titles array.
*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! 'Bars' %>
<%= window_title %>
<%# => 'Foos - Bars' %>
Returns the current Array of window titles.
30 31 32 |
# File 'lib/hierarchical_page_titles/view_helpers.rb', line 30 def window_title!(*titles) controller.window_title!(*titles) end |
#window_title? ⇒ Boolean
Public: Determine whether there are any window titles to display.
Returns true or false.
46 47 48 |
# File 'lib/hierarchical_page_titles/view_helpers.rb', line 46 def window_title? controller.window_title? end |
#window_title_set? ⇒ Boolean
Public: Determine whether any window titles have been set yet.
Returns true or false.
54 55 56 |
# File 'lib/hierarchical_page_titles/view_helpers.rb', line 54 def window_title_set? controller.window_title_set? end |
#window_titles ⇒ Object
Public: Return the array of window titles.
38 39 40 |
# File 'lib/hierarchical_page_titles/view_helpers.rb', line 38 def window_titles controller.window_titles end |