Class: Jekyll::Heroicons

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

Defined Under Namespace

Classes: Icon

Constant Summary collapse

DEFAULT_VARIANT =

In case no variant is specified, use solid as default

"solid"
SYNTAX =

Syntax for the heroicon symbol

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

For interpolation, look for liquid variables

/\{\{\s*(\w+\.?\w*)\s*\}\}/i
TAG_ATTRIBUTES =

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

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tag_name, markup, options) ⇒ Heroicons

Returns a new instance of Heroicons.



31
32
33
34
35
36
37
# File 'lib/jekyll-heroicons.rb', line 31

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

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

Class Method Details

.rootObject



12
13
14
# File 'lib/jekyll-heroicons.rb', line 12

def self.root
  File.dirname(__dir__)
end

Instance Method Details

#render(context) ⇒ Object



39
40
41
42
43
44
45
# File 'lib/jekyll-heroicons.rb', line 39

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

  return nil if @symbol.nil?

  Icon.new(@symbol, @variant, @options.except(:variant, :disable_default_class)).raw
end