Sha256: e732bbdfc3fef8325010fbb6a43b8445fa0417df1c7af20aa66cc9c68e92378c

Contents?: true

Size: 592 Bytes

Versions: 20

Compression:

Stored size: 592 Bytes

Contents

# frozen_string_literal: true

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

20 entries across 20 versions & 2 rubygems

Version Path
octicons_helper-19.15.0 lib/octicons_helper/helper.rb
openproject-octicons_helper-19.20.0 lib/octicons_helper/helper.rb
octicons_helper-19.14.0 lib/octicons_helper/helper.rb
octicons_helper-19.13.0 lib/octicons_helper/helper.rb
openproject-octicons_helper-19.19.0 lib/octicons_helper/helper.rb
openproject-octicons_helper-19.18.1 lib/octicons_helper/helper.rb
octicons_helper-19.12.0 lib/octicons_helper/helper.rb
openproject-octicons_helper-19.18.0 lib/octicons_helper/helper.rb
openproject-octicons_helper-19.17.0 lib/octicons_helper/helper.rb
openproject-octicons_helper-19.16.0 lib/octicons_helper/helper.rb
octicons_helper-19.11.0 lib/octicons_helper/helper.rb
openproject-octicons_helper-19.15.0 lib/octicons_helper/helper.rb
octicons_helper-19.10.0 lib/octicons_helper/helper.rb
openproject-octicons_helper-19.14.1 lib/octicons_helper/helper.rb
openproject-octicons_helper-19.14.0 lib/octicons_helper/helper.rb
openproject-octicons_helper-19.13.0 lib/octicons_helper/helper.rb
openproject-octicons_helper-19.11.0 lib/octicons_helper/helper.rb
openproject-octicons_helper-19.10.0 lib/octicons_helper/helper.rb
openproject-octicons_helper-19.9.0 lib/octicons_helper/helper.rb
octicons_helper-19.9.0 lib/octicons_helper/helper.rb