Class: Jekyll::Octicons

Inherits:
Liquid::Tag show all
Includes:
LiquidExtensions
Defined in:
lib/jekyll-octicons.rb,
lib/jekyll-octicons/version.rb

Constant Summary collapse

Syntax =

Syntax for the octicon symbol

/\A(#{Liquid::VariableSignature}+)/
Variable =

For interpoaltion, look for liquid variables

/\{\{\s*([\w]+\.?[\w]*)\s*\}\}/i
TagAttributes =

Copied from Liquid::TagAttributes to allow dashes in tag names:

{% octicon alert area-label:"Hello World!" %}
/([\w-]+)\s*\:\s*(#{Liquid::QuotedFragment})/o
VERSION =
'1.1.0'.freeze

Instance Method Summary collapse

Constructor Details

#initialize(tag_name, markup, options) ⇒ Octicons

Returns a new instance of Octicons.



22
23
24
25
26
# File 'lib/jekyll-octicons.rb', line 22

def initialize(tag_name, markup, options)
  super
  @markup = markup
  @options = string_to_hash(markup)
end

Instance Method Details

#render(context) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/jekyll-octicons.rb', line 28

def render(context)
  @markup.scan Variable do |variable|
    @options = string_to_hash(@markup.gsub(Variable, lookup_variable(context, variable.first)))
  end
  return nil if @options[:symbol].nil?
  ::Octicons::Octicon.new(@options).to_svg
end