Class: Jekyll::Tabler::OutlineTag
- Inherits:
-
Liquid::Tag
- Object
- Liquid::Tag
- Jekyll::Tabler::OutlineTag
- Defined in:
- lib/jekyll-tabler.rb
Overview
Handles ‘tabler … %` tags.
‘initialize` runs during Liquid parsing, not page rendering, so this method only stores raw arguments. Variable resolution happens later in `render` when the page context is available.
Instance Method Summary collapse
-
#initialize(tag_name, markup, tokens) ⇒ OutlineTag
constructor
rubocop:disable Metrics/AbcSize.
-
#render(context) ⇒ Object
Converts stored arguments into final values for the current page and delegates SVG generation to the shared helper.
Constructor Details
#initialize(tag_name, markup, tokens) ⇒ OutlineTag
rubocop:disable Metrics/AbcSize
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/jekyll-tabler.rb', line 133 def initialize(tag_name, markup, tokens) # rubocop:disable Metrics/AbcSize super args = Shellwords.shellsplit(markup.to_s) raise Liquid::SyntaxError, Jekyll::Tabler. if args.empty? @icon_name = args[0] , positional_args = Jekyll::Tabler.parse_optional_args(args.drop(1)) raise Liquid::SyntaxError, Jekyll::Tabler. if positional_args.length > 2 @size = .fetch("size", positional_args[0] || 24) @color = .fetch("color", positional_args[1] || "currentColor") rescue ArgumentError => e raise Liquid::SyntaxError, e. end |
Instance Method Details
#render(context) ⇒ Object
Converts stored arguments into final values for the current page and delegates SVG generation to the shared helper.
152 153 154 155 156 157 158 |
# File 'lib/jekyll-tabler.rb', line 152 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 |