Class: Jekyll::FontAwesome::Svg::FontAwesomeSvgItemGenerator

Inherits:
Liquid::Tag
  • Object
show all
Defined in:
lib/jekyll/fontawesome/svg/fa-item.rb

Instance Method Summary collapse

Constructor Details

#initialize(tag_name, markup, tokens) ⇒ FontAwesomeSvgItemGenerator

Returns a new instance of FontAwesomeSvgItemGenerator.



7
8
9
10
# File 'lib/jekyll/fontawesome/svg/fa-item.rb', line 7

def initialize(tag_name, markup, tokens)
  super
  @tmp_markup = markup
end

Instance Method Details

#render(context) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/jekyll/fontawesome/svg/fa-item.rb', line 12

def render(context)
  faIcon = context[@markup] ||= @tmp_markup
  @icon = FontAwesomeIcon.new(faIcon.strip)
  
  unless context.environments.first['page']['fa_svg'].is_a?([]::class)
    context.environments.first['page']['fa_svg'] = []
  end
  context.environments.first['page']['fa_svg'].push(@icon.value)
  "<svg class=\"icon\"><use xlink:href='##{@icon.value}'></use></svg>"
end