jekyll_icon_list 0.4.0 → 0.5.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 66af09ff271544ab5afed2a9e28e05769d75337d43dafa32747fc546d1f91f5f
4
- data.tar.gz: 26ebee9c1b1fa4589a3587c2fa9169a5cc18304948e032d639e15cec76e132e9
3
+ metadata.gz: 646c55e10cdc07ca2648f30a38f84283f54a0106ac50caebbfdb672202ae3a03
4
+ data.tar.gz: dbfb66532092ff44ba10afe9059683d953152989a84e13cddf1489cc0c6a0dce
5
5
  SHA512:
6
- metadata.gz: 1b507c5492ac70c6cd0aedd02e56e7f2efdf264733ee280315c086b9d09b734c480700b10c85f5ddb6c8d0903051260e00edc5896de608a93bebad6bf7c6575a
7
- data.tar.gz: 38507a86625e2ec9ab637359bdeaad9ed195b7ede1c22885e5878ec1ff90a6cefa8123f325722ef61567edfc57bd2f6ed7b5085f3a5a559c9e221befec2f5d07
6
+ metadata.gz: cc866f244d2846fcb9c0699591895b305da662a569079b22fdb031cd83756063d2859060b4b9b1bc77bb573eb70fc136c33c022f67e57ad1e815bab666d3c175
7
+ data.tar.gz: e2e450f350c7644ded463974b2fc0d99833c756626bd4d7f4722fa19245d9bd4092467264503fb4e9210ca8205eeb742341773c0de81e7a49bfbdb048c39687d
data/README.md CHANGED
@@ -110,27 +110,34 @@ If you set a `url:`, it'll wrap the `<li>` contents in an anchor tag.
110
110
 
111
111
  ### Liquid Variables:
112
112
 
113
- It will parse liquid variables, as either a yaml array or a space-separated-list. Enclose them in
114
- double curly braces, like this: `{{ my_context.my_variable }}`. **If given multiword variables, it
115
- will attempt to build an item for each word.**
113
+ It will parse liquid variables, as a space-separated-list. Enclose them in
114
+ double curly braces, like this: `{{ my_context.my_variable }}`. **If given
115
+ multiword variables, it will attempt to build an item for each word.**
116
116
 
117
117
  Example:
118
118
 
119
119
  ```
120
120
  ---
121
- category_list:
121
+ categories: skydiving spelunking bouldering
122
+ ---
123
+
124
+
125
+ {% icon_list {{ page.categories }} %}
126
+ ```
127
+
128
+ If you use yaml arrays, you must join them into a space-separated
129
+ string using `| join ' '`:
130
+
131
+ ```
132
+ ---
133
+ categories:
122
134
  - skydiving
123
135
  - spelunking
124
136
  - bouldering
125
-
126
- category_string: skydiving spelunking bouldering
127
137
  ---
128
138
 
129
- {% icon_list {{ page.category_list }} %}
130
-
131
- {% icon_list {{ page.category_string }} %}
139
+ {% icon_list {{ page.categories | join ' ' }} %}
132
140
  ```
133
- (Both icon_list tags will return the same output)
134
141
 
135
142
  ## Configuration
136
143
 
@@ -42,15 +42,18 @@ module JekyllIconList
42
42
  build_html(all_items_data)
43
43
  end
44
44
 
45
+ private
46
+
45
47
  def build_settings
46
48
  @attributes = @icon_list_settings['defaults'].dup || {}
47
49
  # {'ul' => 'class="awesome" (...)', (...)}
48
50
 
49
51
  # raw_input will look something like this:
50
52
  # 'item1 item2 item3 --ul attribute="value" --(...)'
51
- raw_input_array = liquid_lookup(@raw_input).split('--').map do |i|
53
+ raw_input_array = liquid_parse(@raw_input).split('--').map do |i|
52
54
  i.strip.split(' ')
53
55
  end
56
+
54
57
  # [['item1', 'item2', 'item3'], ['ul', 'attr="value', 'value2"'],(...)]
55
58
 
56
59
  @item_shortnames = raw_input_array.shift
@@ -61,18 +64,8 @@ module JekyllIconList
61
64
  # {'ul' => 'attribute="value1 value2 value3"'}
62
65
  end
63
66
 
64
- LIQUID_REGEX = /\{\{\s*([\w]+\.?[\w]*)\s*\}\}/i
65
- def liquid_lookup(input)
66
- # I mostly stole this method from SVG Inliner. There may be a better way,
67
- # but this works well enough.
68
- input.scan LIQUID_REGEX do |match|
69
- value = lookup_variable(@context, match.first)
70
- value = value.join(' ') if value.is_a? Array
71
-
72
- input = input.sub(LIQUID_REGEX, value)
73
- end
74
-
75
- input
67
+ def liquid_parse(input)
68
+ Liquid::Template.parse(input).render(@context)
76
69
  end
77
70
 
78
71
  def build_html(all_items_data)
@@ -140,14 +133,10 @@ module JekyllIconList
140
133
  end
141
134
 
142
135
  def build_svg(icon_filename)
143
- params = icon_filename
144
- params << ' ' + @attributes['svg'] if @attributes['svg']
145
- Jekyll::Tags::JekyllInlineSvg.send(
146
- :new,
147
- 'svg',
148
- params,
149
- @tokens
150
- ).render(@context)
136
+ tag = "{% svg #{icon_filename}"
137
+ tag << ' ' + @attributes['svg'] if @attributes['svg']
138
+ tag << ' %}'
139
+ liquid_parse(tag)
151
140
  end
152
141
 
153
142
  def build_img(icon_filename)
@@ -1,3 +1,3 @@
1
1
  module JekyllIconList
2
- VERSION = '0.4.0'.freeze
2
+ VERSION = '0.5.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll_icon_list
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Buchberger
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-10-08 00:00:00.000000000 Z
11
+ date: 2018-10-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler