Module: BasiconsHelper

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

Defined Under Namespace

Classes: Railtie

Constant Summary collapse

VERSION =
'1.0.3'.freeze

Instance Method Summary collapse

Instance Method Details

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



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/basicons_helper/helper.rb', line 8

def basicon(symbol, options = {})
  return '' if symbol.nil?
  cache_key = [symbol, options]

  if tag = basicons_helper_cache[cache_key]
    tag
  else
    icon = Basicons::Basicon.new(symbol, options)
    tag = (:svg, icon.data.html_safe, icon.options).freeze
    basicons_helper_cache[cache_key] = tag
    tag
  end
end