Class: Jekyll::Tags::UseSvg

Inherits:
Liquid::Tag
  • Object
show all
Defined in:
lib/esvg/jekyll_hooks.rb

Instance Method Summary collapse

Constructor Details

#initialize(tag_name, markup, tokens) ⇒ UseSvg

Returns a new instance of UseSvg.



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/esvg/jekyll_hooks.rb', line 48

def initialize(tag_name, markup, tokens)
  super
  markup.sub!(/(\S+) /) do
    @name = $1.gsub(/[",']/, '')
    ''
  end

  @options = markup.strip.split(/,\s*/).join("\n")

  if @options.empty?
    @options = {}
  else
    @options = Esvg.deep_symbolize_hash_keys(YAML.load(@options)) unless @options.empty?
  end
end

Instance Method Details

#render(context) ⇒ Object



64
65
66
# File 'lib/esvg/jekyll_hooks.rb', line 64

def render(context)
  Esvg.use(@name, @options)
end