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
-
#app_title ⇒ String
Shorthand for calling
title.app
in the view. -
#page_title ⇒ String
Shorthand for calling
title.page
in the view. -
#title(context = {}) ⇒ Titleist::Title
Generate the full page title for this request.
-
#title=(new_title) ⇒ String
Override the current page title.
-
#title_tag(context = {}) ⇒ ActiveSupport::SafeBuffer
Full <title> tag renderer that uses the current page title and wraps it in the proper HTML element.
Instance Method Details
#app_title ⇒ String
Shorthand for calling title.app
in the view.
37 38 39 |
# File 'app/helpers/titleist_helper.rb', line 37 def app_title title.app end |
#page_title ⇒ String
Shorthand for calling title.page
in the view.
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.
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.
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.
8 9 10 |
# File 'app/helpers/titleist_helper.rb', line 8 def title_tag(context = {}) content_tag :title, title(context).to_s.html_safe end |