jekyll-tabler 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +43 -0
- data/lib/filled_data.rb +1061 -0
- data/lib/jekyll-tabler.rb +9 -40
- data/lib/outline_data.rb +5101 -0
- data/lib/version.rb +1 -1
- metadata +7 -21
- data/assets/filled.yml +0 -2613
- data/assets/outline.yml +0 -25659
data/lib/jekyll-tabler.rb
CHANGED
|
@@ -1,27 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# Copyright (c) 2026 phothinmg
|
|
4
|
-
# <https://github.com/phothinmg/jekyll-tabler>
|
|
5
|
-
|
|
6
3
|
require "jekyll"
|
|
7
|
-
require "fileutils"
|
|
8
4
|
require "shellwords"
|
|
9
|
-
require "yaml"
|
|
10
5
|
|
|
11
6
|
require_relative "version"
|
|
12
7
|
|
|
13
8
|
# Main plugin entrypoint.
|
|
14
|
-
#
|
|
15
|
-
# Flow overview for maintainers:
|
|
16
|
-
# 1. This file is required by Jekyll when the plugin is listed in `_config.yml`.
|
|
17
|
-
# 2. The two Liquid tags are registered at the bottom of the file.
|
|
18
|
-
# 3. When Jekyll parses a page containing `{% tabler %}` or
|
|
19
|
-
# `{% tabler_filled %}`, Liquid instantiates the matching tag class and
|
|
20
|
-
# runs `initialize` once to parse the markup.
|
|
21
|
-
# 4. During page rendering, Liquid calls `render`, which resolves literal
|
|
22
|
-
# values or Liquid variables from the page context.
|
|
23
|
-
# 5. The resolved icon name is looked up in the packaged YAML asset and then
|
|
24
|
-
# wrapped in SVG markup for the final HTML output.
|
|
25
9
|
module Jekyll
|
|
26
10
|
# Shared helpers and Liquid tag implementations for Tabler icons.
|
|
27
11
|
module Tabler
|
|
@@ -31,17 +15,16 @@ module Jekyll
|
|
|
31
15
|
|
|
32
16
|
module_function
|
|
33
17
|
|
|
34
|
-
#
|
|
35
|
-
#
|
|
36
|
-
# The YAML files map an icon name to one or more SVG path definitions.
|
|
37
|
-
# This is the only place where the plugin reaches into packaged assets.
|
|
18
|
+
# Lazy-loads the precompiled Ruby file only when a specific icon set is first requested.
|
|
19
|
+
# This keeps Jekyll startup speeds instant.
|
|
38
20
|
def tabler_icons(type)
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
21
|
+
if type == "filled"
|
|
22
|
+
require_relative "filled_data" unless defined?(FILLED_DATA)
|
|
23
|
+
FILLED_DATA # Ruby reuses this native constant instantly; no extra cache needed
|
|
24
|
+
else
|
|
25
|
+
require_relative "outline_data" unless defined?(OUTLINE_DATA)
|
|
26
|
+
OUTLINE_DATA # Ruby reuses this native constant instantly; no extra cache needed
|
|
27
|
+
end
|
|
45
28
|
end
|
|
46
29
|
|
|
47
30
|
# Builds the outline SVG after render-time values have been resolved.
|
|
@@ -102,9 +85,6 @@ module Jekyll
|
|
|
102
85
|
end
|
|
103
86
|
|
|
104
87
|
# Splits optional arguments into named options and positional arguments.
|
|
105
|
-
#
|
|
106
|
-
# Named options are validated here so each tag class can keep its
|
|
107
|
-
# initializer focused on assigning the final values.
|
|
108
88
|
def parse_optional_args(arguments) # rubocop:disable Metrics/MethodLength
|
|
109
89
|
arguments.each_with_object([{}, []]) do |argument, memo|
|
|
110
90
|
options = memo[0]
|
|
@@ -125,10 +105,6 @@ module Jekyll
|
|
|
125
105
|
end
|
|
126
106
|
|
|
127
107
|
# Handles `{% tabler ... %}` tags.
|
|
128
|
-
#
|
|
129
|
-
# `initialize` runs during Liquid parsing, not page rendering, so this
|
|
130
|
-
# method only stores raw arguments. Variable resolution happens later in
|
|
131
|
-
# `render` when the page context is available.
|
|
132
108
|
class OutlineTag < Liquid::Tag
|
|
133
109
|
def initialize(tag_name, markup, tokens) # rubocop:disable Metrics/AbcSize
|
|
134
110
|
super
|
|
@@ -147,8 +123,6 @@ module Jekyll
|
|
|
147
123
|
raise Liquid::SyntaxError, e.message
|
|
148
124
|
end
|
|
149
125
|
|
|
150
|
-
# Converts stored arguments into final values for the current page and
|
|
151
|
-
# delegates SVG generation to the shared helper.
|
|
152
126
|
def render(context)
|
|
153
127
|
icon_name = Jekyll::Tabler.resolve_argument(@icon_name, context)
|
|
154
128
|
size = Jekyll::Tabler.resolve_argument(@size, context)
|
|
@@ -159,9 +133,6 @@ module Jekyll
|
|
|
159
133
|
end
|
|
160
134
|
|
|
161
135
|
# Handles `{% tabler_filled ... %}` tags.
|
|
162
|
-
#
|
|
163
|
-
# The control flow mirrors `OutlineTag`; the only behavior difference is
|
|
164
|
-
# the final SVG wrapper that uses filled icon data.
|
|
165
136
|
class FilledTag < Liquid::Tag
|
|
166
137
|
def initialize(tag_name, markup, tokens) # rubocop:disable Metrics/AbcSize
|
|
167
138
|
super
|
|
@@ -180,8 +151,6 @@ module Jekyll
|
|
|
180
151
|
raise Liquid::SyntaxError, e.message
|
|
181
152
|
end
|
|
182
153
|
|
|
183
|
-
# Converts stored arguments into final values for the current page and
|
|
184
|
-
# delegates SVG generation to the shared helper.
|
|
185
154
|
def render(context)
|
|
186
155
|
icon_name = Jekyll::Tabler.resolve_argument(@icon_name, context)
|
|
187
156
|
size = Jekyll::Tabler.resolve_argument(@size, context)
|