Module: OcticonsHelper

Includes:
ActionView::Helpers::TagHelper
Defined in:
lib/octicons_helper/helper.rb,
lib/octicons_helper/railtie.rb,
lib/octicons_helper/version.rb

Defined Under Namespace

Classes: Railtie

Constant Summary collapse

VERSION =
"19.14.0".freeze

Instance Method Summary collapse

Instance Method Details

#octicon(symbol, options = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/octicons_helper/helper.rb', line 11

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 = (:svg, icon.path.html_safe, icon.options).freeze # rubocop:disable Rails/OutputSafety
    octicons_helper_cache[cache_key] = tag
    tag
  end
end