Sha256: 953fe09eb0f80f86b7c18566e7548fbd8cfab3e7788ad3eaa4180b9992caa197

Contents?: true

Size: 626 Bytes

Versions: 1

Compression:

Stored size: 626 Bytes

Contents

module Axel
  module ApplicationHelper
    def page_title
      result = controller_params_to_locale
      result ? " - #{result}" : ""
    end

    private

    def controller_params_to_locale
      sections = params[:controller].to_s.split("/").compact.map(&:to_sym)
      action = params[:action].to_s.to_sym
      title = t(:titles)

      sections.each do |s|
        title = title.send("[]", s) if title.is_a?(Hash)
      end
      if title.is_a? Hash
        title[action]
      elsif title.is_a?(String) && !title.match(/class=\"translation_missing\"/)
        title
      else
        nil
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
axel-0.0.1 lib/axel/application_helper.rb