Module: PageTitleHelper
- Defined in:
- app/helpers/page_title_helper.rb
Instance Method Summary collapse
-
#page_title(new_title = nil, options = {}) ⇒ String
Sets or retrieves the current page title.
Instance Method Details
#page_title(new_title = nil, options = {}) ⇒ String
Sets or retrieves the current page title.
-
When given no argument, this will return the currently set page title or the site-wide default.
-
When given a string argument, that will be used in the formatted page title (for example with a site-wide suffix).
-
When given an ActiveModel-compliant object, its singular and plural human names will be interpolated into the model-based title template, along with the record’s ID.
You can provide templates for page titles using ‘I18n` in three broad categories: the `model`, `formatted` and `standard` keys. These will be used when you set a page title via a model, string or nothing at all, respectively.
You can specify these translation keys on a global default level, per controller or per controller action. The more specific key will take precedence.
33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/helpers/page_title_helper.rb', line 33 def page_title(new_title = nil, = {}) if new_title title_from_string_or_record_or_class(new_title, ).tap do |str| content_for :page_title, str end elsif content_for? :page_title formatted_title else standard_title end end |