Class: Jekyll::Tabler::OutlineTag

Inherits:
Liquid::Tag
  • Object
show all
Defined in:
lib/jekyll-tabler.rb

Overview

class Jekyll::Tabler::OutlineTag

Instance Method Summary collapse

Constructor Details

#initialize(tag_name, markup, tokens) ⇒ OutlineTag

rubocop:disable Metrics/AbcSize



100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/jekyll-tabler.rb', line 100

def initialize(tag_name, markup, tokens) # rubocop:disable Metrics/AbcSize
  super

  args = Shellwords.shellsplit(markup.to_s)
  raise Liquid::SyntaxError, Jekyll::Tabler.syntax_message if args.empty?

  @icon_name = args[0]
  options, positional_args = Jekyll::Tabler.parse_optional_args(args.drop(1))

  raise Liquid::SyntaxError, Jekyll::Tabler.syntax_message if positional_args.length > 2

  @size = options.fetch("size", positional_args[0] || 24)
  @color = options.fetch("color", positional_args[1] || "currentColor")
rescue ArgumentError => e
  raise Liquid::SyntaxError, e.message
end

Instance Method Details

#render(context) ⇒ Object



117
118
119
120
121
122
123
# File 'lib/jekyll-tabler.rb', line 117

def render(context)
  icon_name = Jekyll::Tabler.resolve_argument(@icon_name, context)
  size = Jekyll::Tabler.resolve_argument(@size, context)
  color = Jekyll::Tabler.resolve_argument(@color, context)

  Jekyll::Tabler.outline_wrapper(icon_name, size, color)
end