Sha256: 5c36872b161e39cd2c84a934100bf155376877acfbe23238d0f58d53e63bdc2c

Contents?: true

Size: 1.27 KB

Versions: 4

Compression:

Stored size: 1.27 KB

Contents

# frozen_string_literal: true

# Methods added to this helper will be available to all templates in the hosting application
module Blacklight::BlacklightHelperBehavior
  include Blacklight::UrlHelperBehavior
  include Blacklight::LayoutHelperBehavior
  include Blacklight::IconHelperBehavior

  ##
  # Get the name of this application from an i18n string
  # key: blacklight.application_name
  # Try first in the current locale, then the default locale
  #
  # @return [String] the application name
  def application_name
    # It's important that we don't use ActionView::Helpers::CacheHelper#cache here
    # because it returns nil.
    Rails.cache.fetch 'blacklight/application_name' do
      t('blacklight.application_name',
        default: t('blacklight.application_name', locale: I18n.default_locale))
    end
  end

  ##
  # Render a partial of an arbitrary format inside a
  # template of a different format. (e.g. render an HTML
  # partial from an XML template)
  # code taken from:
  # http://stackoverflow.com/questions/339130/how-do-i-render-a-partial-of-a-different-format-in-rails (zgchurch)
  #
  # @param [String] format suffix
  # @yield
  def with_format(format)
    old_formats = formats
    self.formats = [format]
    yield
    self.formats = old_formats
    nil
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
blacklight-8.0.0 app/helpers/blacklight/blacklight_helper_behavior.rb
blacklight-8.0.0.beta8 app/helpers/blacklight/blacklight_helper_behavior.rb
blacklight-8.0.0.beta7 app/helpers/blacklight/blacklight_helper_behavior.rb
blacklight-8.0.0.beta6 app/helpers/blacklight/blacklight_helper_behavior.rb