Sha256: 385c8e32a6e4cb7cebe319bf3e9cbb3aedbed912d8056cffa662516542d9add5

Contents?: true

Size: 925 Bytes

Versions: 1

Compression:

Stored size: 925 Bytes

Contents

# typed: false

module Titleist
  # Controller mixins for reading titles without ActionView
  module Controller
    extend ActiveSupport::Concern
    extend T::Sig

    included do
      helper_method :title, :app_title, :page_title
    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
      @title ||= Title.new(**params.to_unsafe_h.deep_symbolize_keys)
    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
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
titleist-1.0.0 lib/titleist/controller.rb