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 =
"9.6.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
27
28
# File 'lib/jekyll-octicons.rb', line 22

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

  # If there's interpoaltion going on, we need to do this in render
  prepare(markup) unless match = markup.match(Variable)
end

Instance Method Details

#render(context) ⇒ Object



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

def render(context)
  prepare(interpolate(@markup, context)) if match = @markup.match(Variable)

  return nil if @symbol.nil?
  ::Octicons::Octicon.new(@symbol, @options).to_svg
end