Sha256: 64e182160cd4a58a8ac8851430cf3b67c7847af57328707361c4a9ef1ed6ce6e

Contents?: true

Size: 532 Bytes

Versions: 1

Compression:

Stored size: 532 Bytes

Contents

require "forticons"
require "action_view"

module ForticonsHelper
  include ActionView::Helpers::TagHelper

  mattr_accessor :forticons_helper_cache, default: {}

  def forticon(symbol, options = {})
    return "" if symbol.nil?

    cache_key = [symbol, options]

    if tag = forticons_helper_cache[cache_key]
      tag
    else
      icon = Forticons::Forticon.new(symbol, options)

      tag = content_tag(:svg, icon.path.html_safe, icon.options).freeze
      forticons_helper_cache[cache_key] = tag
      tag
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
forticons_helper-0.0.4 lib/forticons_helper/helper.rb