Sha256: 9eb4981dc14c25ed79a718ac8876e86e38eb5f75d6062b30394c920ee39e79d8

Contents?: true

Size: 595 Bytes

Versions: 6

Compression:

Stored size: 595 Bytes

Contents

# frozen_string_literal: true

##
# Module to help generate icon helpers for SVG images
module Blacklight::IconHelperBehavior
  ##
  # Returns the raw SVG (String) for a Blacklight Icon located in
  # app/assets/images/blacklight/*.svg. Caches them so we don't have to look up
  # the svg everytime.
  # @param [String, Symbol] icon_name
  # @return [String]
  def blacklight_icon(icon_name, options = {})
    Rails.cache.fetch([:blacklight_icons, icon_name, options]) do
      icon = Blacklight::Icon.new(icon_name, **options)
      tag.span(icon.svg.html_safe, icon.options)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
blacklight-7.13.2 app/helpers/blacklight/icon_helper_behavior.rb
blacklight-7.13.1 app/helpers/blacklight/icon_helper_behavior.rb
blacklight-7.13.0 app/helpers/blacklight/icon_helper_behavior.rb
blacklight-7.12.1 app/helpers/blacklight/icon_helper_behavior.rb
blacklight-7.12.0 app/helpers/blacklight/icon_helper_behavior.rb
blacklight-7.11.1 app/helpers/blacklight/icon_helper_behavior.rb