Sha256: 7e22d246c46418ab5a433d20dd0f62e69d0790887b3dc9be411ad432b119e0b8

Contents?: true

Size: 890 Bytes

Versions: 2

Compression:

Stored size: 890 Bytes

Contents

module I18nDashboard
  module ApplicationHelper
    def title(page_title, show_title = true)
      @show_title = show_title
      if @show_title
        content_for(:title) { h(page_title.to_s) }
      end
    end

    def show_title?
      @show_title
    end

    def humanize_key(key)
      key.split('.').last.gsub('_', ' ').gsub(/\b('?[a-z])/) { $1.capitalize }
    end

    # Can search for named routes directly in the main app, omitting
    # the "main_app." prefix
    def method_missing method, *args, &block
      if main_app_url_helper?(method)
        main_app.send(method, *args)
      else
        super
      end
    end

    private

    def main_app_url_helper?(method)
      I18nDashboard::configuration.inline_main_app_named_routes and
        (method.to_s.end_with?('_path') or method.to_s.end_with?('_url')) and
        main_app.respond_to?(method)
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
i18n_dashboard-0.1.5 app/helpers/i18n_dashboard/application_helper.rb
i18n_dashboard-0.1.4 app/helpers/i18n_dashboard/application_helper.rb