Sha256: 35e42f2db007c1f56848d80dbcbaf7bc2bb3aa93eb183a4ae1924f06d1505ed3

Contents?: true

Size: 589 Bytes

Versions: 108

Compression:

Stored size: 589 Bytes

Contents

require "octicons"
require "action_view"

module OcticonsHelper
  include ActionView::Helpers::TagHelper

  mattr_accessor :octicons_helper_cache, default: {}

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

    cache_key = [symbol, options].to_s

    if octicons_helper_cache[cache_key]
      octicons_helper_cache[cache_key]
    else
      icon = Octicons::Octicon.new(symbol, options)

      tag = content_tag(:svg, icon.path.html_safe, icon.options).freeze # rubocop:disable Rails/OutputSafety
      octicons_helper_cache[cache_key] = tag
      tag
    end
  end
end

Version data entries

108 entries across 108 versions & 1 rubygems

Version Path
octicons_helper-12.0.0.pre.e0e204f lib/octicons_helper/helper.rb
octicons_helper-12.0.0.pre.b98ee37 lib/octicons_helper/helper.rb
octicons_helper-12.0.0.pre.f6726ed lib/octicons_helper/helper.rb
octicons_helper-12.0.0.pre.2f1811e lib/octicons_helper/helper.rb
octicons_helper-0.0.0.pre.715a5fc lib/octicons_helper/helper.rb
octicons_helper-0.0.0.pre.2b5b678 lib/octicons_helper/helper.rb
octicons_helper-0.0.0.pre.d01f11f lib/octicons_helper/helper.rb
octicons_helper-0.0.0.pre.dbeb070 lib/octicons_helper/helper.rb
octicons_helper-0.0.0.pre.6c7ba83 lib/octicons_helper/helper.rb
octicons_helper-0.0.0.pre.ea5c231 lib/octicons_helper/helper.rb
octicons_helper-0.0.0.pre.92931a8 lib/octicons_helper/helper.rb
octicons_helper-0.0.0.pre.92cad69 lib/octicons_helper/helper.rb
octicons_helper-0.0.0.pre.bb63a00 lib/octicons_helper/helper.rb
octicons_helper-0.0.0.pre.38555f8 lib/octicons_helper/helper.rb
octicons_helper-0.0.0.pre.c89efd4 lib/octicons_helper/helper.rb
octicons_helper-0.0.0.pre.815e37f lib/octicons_helper/helper.rb
octicons_helper-0.0.0.pre.df8cca5 lib/octicons_helper/helper.rb
octicons_helper-0.0.0.pre.5476cec lib/octicons_helper/helper.rb
octicons_helper-0.0.0.pre.2780cb9 lib/octicons_helper/helper.rb
octicons_helper-0.0.0.pre.b1a25d5 lib/octicons_helper/helper.rb