Module: TitleistHelper

Defined in:
app/helpers/titleist_helper.rb

Overview

Helper methods included into ActionView for rendering the current page and application title.

Instance Method Summary collapse

Instance Method Details

#app_titleString

Shorthand for calling title.app in the view.

Returns:

  • (String)

    i18n-configured global application title.



37
38
39
# File 'app/helpers/titleist_helper.rb', line 37

def app_title
  title.app
end

#page_titleString

Shorthand for calling title.page in the view.

Returns:

  • (String)

    i18n-configured title for the current page.



44
45
46
# File 'app/helpers/titleist_helper.rb', line 44

def page_title
  title.page
end

#title(context = {}) ⇒ Titleist::Title

Generate the full page title for this request. When output into the view, the entire title is shown. You may also call title.page or title.app to view individual pieces of the title.

Returns:



17
18
19
20
21
22
23
24
# File 'app/helpers/titleist_helper.rb', line 17

def title(context = {})
  @title ||= Titleist::Title.new(
    controller: controller.controller_name,
    action: controller.action_name,
    context: context,
    root: current_page?(root_path)
  )
end

#title=(new_title) ⇒ String

Override the current page title.

Parameters:

  • new_title (String)

Returns:

  • (String)


30
31
32
# File 'app/helpers/titleist_helper.rb', line 30

def title=(new_title)
  title.page = new_title
end

#title_tag(context = {}) ⇒ ActiveSupport::SafeBuffer

Full <title> tag renderer that uses the current page title and wraps it in the proper HTML element.

Returns:

  • (ActiveSupport::SafeBuffer)


8
9
10
# File 'app/helpers/titleist_helper.rb', line 8

def title_tag(context = {})
   :title, title(context).to_s.html_safe
end