Sha256: 82580cc65fc7001340d4111b6ea55be4d5a31013d8a0f25344d00b35126bb038

Contents?: true

Size: 1.22 KB

Versions: 1

Compression:

Stored size: 1.22 KB

Contents

# Helper methods included into +ActionView+ for rendering the current
# page and application title.
module TitleistHelper
  # Full +<title>+ tag renderer that uses the current page title and
  # wraps it in the proper HTML element.
  #
  # @return [ActiveSupport::SafeBuffer]
  def title_tag(context = {})
    content_tag :title, title(context).to_s.html_safe
  end

  # 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.
  #
  # @return [Titleist::Title]
  def title(context = {})
    @title ||= Titleist::Title.new(
      controller: controller.controller_name,
      action: controller.action_name,
      context: context
    )
  end

  # Override the current page title.
  #
  # @param [String] new_title
  # @return [String]
  def title=(new_title)
    title.page = new_title
  end

  # Shorthand for calling +title.app+ in the view.
  #
  # @return [String] i18n-configured global application title.
  def app_title
    title.app
  end

  # Shorthand for calling +title.page+ in the view.
  #
  # @return [String] i18n-configured title for the current page.
  def page_title
    title.page
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
titleist-0.1.0 app/helpers/titleist_helper.rb