Module: HierarchicalPageTitles::SharedMethods

Included in:
ControllerHelpers, ViewHelpers
Defined in:
lib/hierarchical_page_titles/shared_methods.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) page_title(*args, &block)

Call this in your view with a string to set the page title to that string. Call this in your layout with no arguments to output the page title.



20
21
22
23
24
25
# File 'lib/hierarchical_page_titles/shared_methods.rb', line 20

def page_title(*args, &block)
  options = args.extract_options!
  title = args.first
  @_page_title = (block_given? ? block.call : title)
  @_page_title_set = true
end

- (Object) title(*args, &block)

Call this in your view to set the window title and the page title at the same time. See window_title and page_title for more.



29
30
31
32
33
34
# File 'lib/hierarchical_page_titles/shared_methods.rb', line 29

def title(*args, &block)
  options = args.extract_options!
  window_title(*args, &block)
  page_title(args.last, &block)
  @_title_set = true
end

- (Object) titles



36
37
38
# File 'lib/hierarchical_page_titles/shared_methods.rb', line 36

def titles
  @_window_titles
end

- (Object) window_title(*args, &block)

Call this in your view with a string to add the string to the array of window titles. Call this in your layout to output the window title. You can specify a separator that should be put between the titles by passing :separator => " - ".



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/hierarchical_page_titles/shared_methods.rb', line 6

def window_title(*args, &block)
  options = args.extract_options!
  titles = args.flatten
  @_window_titles ||= []
  if block_given?
    @_window_titles << block.call
  else
    @_window_titles += titles
  end
  @_window_title_set = true
end