Class: Jekyll::Tabler::FilledTag

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) ⇒ FilledTag

rubocop:disable Metrics/AbcSize



128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/jekyll-tabler.rb', line 128

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



145
146
147
148
149
150
151
# File 'lib/jekyll-tabler.rb', line 145

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.filled_wrapper(icon_name, size, color)
end