Sha256: bc0ecbd81530c3a973d54e1a3473d3a51043d764696742257aed47b1cce5ef5b

Contents?: true

Size: 561 Bytes

Versions: 342

Compression:

Stored size: 561 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]

    if tag = octicons_helper_cache[cache_key]
      tag
    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

342 entries across 342 versions & 2 rubygems

Version Path
openproject-octicons_helper-19.8.0 lib/octicons_helper/helper.rb
octicons_helper-19.8.0 lib/octicons_helper/helper.rb
openproject-octicons_helper-19.7.0 lib/octicons_helper/helper.rb
octicons_helper-19.7.0 lib/octicons_helper/helper.rb
octicons_helper-19.6.0 lib/octicons_helper/helper.rb
openproject-octicons_helper-19.6.7 lib/octicons_helper/helper.rb
openproject-octicons_helper-19.6.6 lib/octicons_helper/helper.rb
octicons_helper-19.5.0 lib/octicons_helper/helper.rb
openproject-octicons_helper-19.6.5 lib/octicons_helper/helper.rb
openproject-octicons_helper-19.6.4 lib/octicons_helper/helper.rb
openproject-octicons_helper-19.6.3 lib/octicons_helper/helper.rb
openproject-octicons_helper-19.6.2 lib/octicons_helper/helper.rb
openproject-octicons_helper-19.6.1 lib/octicons_helper/helper.rb
openproject-octicons_helper-19.5.7 lib/octicons_helper/helper.rb
openproject-octicons_helper-19.5.6 lib/octicons_helper/helper.rb
openproject-octicons_helper-19.5.5 lib/octicons_helper/helper.rb
openproject-octicons_helper-19.5.4 lib/octicons_helper/helper.rb
openproject-octicons_helper-19.5.3 lib/octicons_helper/helper.rb
openproject-octicons_helper-19.5.2 lib/octicons_helper/helper.rb
openproject-octicons_helper-19.5.1 lib/octicons_helper/helper.rb