asciisourcerer 0.3.1 → 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 +4 -4
- data/BILL_OF_MATERIALS.adoc +17 -0
- data/README.adoc +107 -26
- data/lib/sourcerer/_docs/partials/liquid-filters-by-kind.adoc +3227 -0
- data/lib/sourcerer/_docs/partials/liquid-filters-by-source.adoc +3155 -0
- data/lib/sourcerer/asciidoc.rb +52 -10
- data/lib/sourcerer/builder.rb +1 -1
- data/lib/sourcerer/jekyll/bootstrapper.rb +1 -1
- data/lib/sourcerer/jekyll/liquid/filters.rb +295 -0
- data/lib/sourcerer/jekyll.rb +7 -2
- data/lib/sourcerer/mark_down_grade.rb +321 -33
- data/lib/sourcerer/rendering.rb +10 -4
- data/lib/sourcerer/source_skim/config.rb +8 -2
- data/lib/sourcerer/source_skim/ruby_skimmer.rb +83 -0
- data/lib/sourcerer/source_skim/skimmer.rb +94 -1
- data/lib/sourcerer/source_skim.rb +11 -2
- data/lib/sourcerer/util/gem_uri.rb +34 -0
- data/lib/sourcerer/version.rb +1 -1
- data/lib/sourcerer.rb +0 -1
- data/specs/data/liquid-filters.yml +1314 -0
- metadata +22 -3
- data/specs/docs/frontmatter-reader_prd.adoc +0 -47
|
@@ -0,0 +1,1314 @@
|
|
|
1
|
+
filters:
|
|
2
|
+
|
|
3
|
+
- key: date_to_xml_schema
|
|
4
|
+
name: Date to XML Schema
|
|
5
|
+
source: jekyll
|
|
6
|
+
description: Convert a Date into XML Schema (ISO 8601) format.
|
|
7
|
+
tags: [string, date, conversion]
|
|
8
|
+
kind: date-format
|
|
9
|
+
examples:
|
|
10
|
+
- input: '{{ "2008-11-07 1:07:54pm" | date_to_xmlschema }}'
|
|
11
|
+
output: '2008-11-07T13:07:54-08:00'
|
|
12
|
+
|
|
13
|
+
- key: date_to_rfc822
|
|
14
|
+
name: Date to RFC-822 Format
|
|
15
|
+
source: jekyll
|
|
16
|
+
description: Convert a Date into the RFC-822 format used for RSS feeds.
|
|
17
|
+
tags: [string, date, conversion]
|
|
18
|
+
kind: date-format
|
|
19
|
+
examples:
|
|
20
|
+
- input: '{{ data.time | date_to_rfc822 }}'
|
|
21
|
+
output: 'Fri, 07 Nov 2008 13:07:54 -0800'
|
|
22
|
+
|
|
23
|
+
- key: date_to_string
|
|
24
|
+
name: Date to String
|
|
25
|
+
source: jekyll
|
|
26
|
+
description: Convert a date to short format.
|
|
27
|
+
tags: [string, date, conversion]
|
|
28
|
+
kind: date-format
|
|
29
|
+
examples:
|
|
30
|
+
- input: '{{ data.time | date_to_string }}'
|
|
31
|
+
output: '07 Nov 2008'
|
|
32
|
+
- input: '{{ data.time | date_to_string: "ordinal", "US" }}'
|
|
33
|
+
output: 'Nov 7th, 2008'
|
|
34
|
+
|
|
35
|
+
- key: date_to_long_string
|
|
36
|
+
name: Date to Long String
|
|
37
|
+
source: jekyll
|
|
38
|
+
description: Format a date to long format.
|
|
39
|
+
tags: [string, date, conversion]
|
|
40
|
+
kind: date-format
|
|
41
|
+
examples:
|
|
42
|
+
- input: '{{ data.time | date_to_long_string }}'
|
|
43
|
+
output: '07 November 2008'
|
|
44
|
+
- input: '{{ data.time | date_to_long_string: "ordinal" }}'
|
|
45
|
+
output: '7th November 2008'
|
|
46
|
+
|
|
47
|
+
- key: where
|
|
48
|
+
name: Where
|
|
49
|
+
source: jekyll
|
|
50
|
+
description: Select all the objects in an array where the key has the given value.
|
|
51
|
+
tags: [array]
|
|
52
|
+
kind: array-select
|
|
53
|
+
examples:
|
|
54
|
+
- input: |
|
|
55
|
+
{% assign filtered = data.users | where:"level", 2 %}
|
|
56
|
+
{{ filtered | size }}
|
|
57
|
+
output: '1'
|
|
58
|
+
- output: '{"user":"alice","level":1}'
|
|
59
|
+
input: |
|
|
60
|
+
{% assign member = data.users | where:"user","alice" %}
|
|
61
|
+
{{ member[0] | jsonify }}
|
|
62
|
+
notes: To express a lone result record, use `result_var[0]`.
|
|
63
|
+
|
|
64
|
+
- key: where_exp
|
|
65
|
+
name: Where Expression
|
|
66
|
+
source: jekyll
|
|
67
|
+
description: Select all the objects in an array where the expression is true.
|
|
68
|
+
tags: [array]
|
|
69
|
+
kind: array-select
|
|
70
|
+
examples:
|
|
71
|
+
- output: '[{"user":"andie","grad_year":2014,"projects":["fooman","barbaz"]},{"user":"lonnie","grad_year":2014,"projects":["fooman"]}]'
|
|
72
|
+
input: |
|
|
73
|
+
{{ data.members | where_exp:"item",
|
|
74
|
+
"item.grad_year == 2014" | jsonify }}
|
|
75
|
+
- output: '[{"user":"cindy","grad_year":2012,"projects":["fooman","foobar"]}]'
|
|
76
|
+
input: |
|
|
77
|
+
{{ data.members | where_exp:"item",
|
|
78
|
+
"item.grad_year < 2014" | jsonify }}
|
|
79
|
+
- output: '[{"user":"andie","grad_year":2014,"projects":["fooman","barbaz"]}]'
|
|
80
|
+
input: |
|
|
81
|
+
{{ data.members | where_exp:"item",
|
|
82
|
+
"item.projects contains 'barbaz'" | jsonify }}
|
|
83
|
+
|
|
84
|
+
- key: group_by
|
|
85
|
+
name: Group By
|
|
86
|
+
source: jekyll
|
|
87
|
+
description: Group an array's items by a given property.
|
|
88
|
+
tags: [array]
|
|
89
|
+
kind: array-organizing
|
|
90
|
+
examples:
|
|
91
|
+
- input: |
|
|
92
|
+
{% assign grouped = data.members | group_by:"grad_year" | first %}
|
|
93
|
+
{{ grouped.name }}
|
|
94
|
+
output: '2014'
|
|
95
|
+
|
|
96
|
+
- key: group_by_exp
|
|
97
|
+
name: Group By Expression
|
|
98
|
+
source: jekyll
|
|
99
|
+
description: Group an array's items using a Liquid expression.
|
|
100
|
+
tags: [array]
|
|
101
|
+
kind: array-organizing
|
|
102
|
+
examples:
|
|
103
|
+
- input: |-
|
|
104
|
+
{{ data.members | group_by_exp: "item", "item.grad_year" | map: "name" | join: "," }}
|
|
105
|
+
output: '2014,2012'
|
|
106
|
+
|
|
107
|
+
- key: xml_escape
|
|
108
|
+
name: XML Escape
|
|
109
|
+
source: jekyll
|
|
110
|
+
description: Escape some text for use in XML.
|
|
111
|
+
kind: string-escape
|
|
112
|
+
examples:
|
|
113
|
+
- input: '{{ "<strong>some text</strong>" | xml_escape }}'
|
|
114
|
+
output: '<strong>some text</strong>'
|
|
115
|
+
|
|
116
|
+
- key: cgi_escape
|
|
117
|
+
name: CGI Escape
|
|
118
|
+
source: jekyll
|
|
119
|
+
description: |
|
|
120
|
+
CGI escape a string for use in a URL.
|
|
121
|
+
Replaces any special characters with appropriate `%XX` replacements.
|
|
122
|
+
CGI escape normally replaces a space with a plus `+` sign.
|
|
123
|
+
kind: string-escape
|
|
124
|
+
examples:
|
|
125
|
+
- input: '{{ "foo, bar; baz?" | cgi_escape }}'
|
|
126
|
+
output: 'foo%2C+bar%3B+baz%3F'
|
|
127
|
+
|
|
128
|
+
- key: uri_escape
|
|
129
|
+
name: URI Escape
|
|
130
|
+
source: jekyll
|
|
131
|
+
description: |
|
|
132
|
+
Percent encodes any special characters in a URI.
|
|
133
|
+
URI escape normally replaces a space with `%20`.
|
|
134
|
+
link:https://en.wikipedia.org/wiki/Percent-encoding#Types_of_URI_characters[Reserved characters]
|
|
135
|
+
will not be escaped.
|
|
136
|
+
kind: string-escape
|
|
137
|
+
examples:
|
|
138
|
+
- input: '{{ "http://foo.com/?q=foo, \bar?" | uri_escape }}'
|
|
139
|
+
output: 'http://foo.com/?q=foo,%20%5Cbar?'
|
|
140
|
+
|
|
141
|
+
- key: number_of_words
|
|
142
|
+
name: Number of Words
|
|
143
|
+
source: jekyll
|
|
144
|
+
description: Count the number of words in a text.
|
|
145
|
+
tags: [string]
|
|
146
|
+
kind: string-analysis
|
|
147
|
+
examples:
|
|
148
|
+
- input: '{{ page.content | number_of_words }}'
|
|
149
|
+
output: '3'
|
|
150
|
+
|
|
151
|
+
- key: array_to_sentence_string
|
|
152
|
+
name: Array to Sentence
|
|
153
|
+
source: jekyll
|
|
154
|
+
description: |
|
|
155
|
+
Convert an array into a sentence. Useful for listing tags.
|
|
156
|
+
Optional argument for connector.
|
|
157
|
+
kind: object-conversion
|
|
158
|
+
examples:
|
|
159
|
+
- input: '{{ tags_array | array_to_sentence_string }}'
|
|
160
|
+
output: 'foo, bar, and baz'
|
|
161
|
+
- input: '{{ tags_array | array_to_sentence_string: "or" }}'
|
|
162
|
+
output: 'foo, bar, or baz'
|
|
163
|
+
|
|
164
|
+
- key: slugify
|
|
165
|
+
name: Slugify
|
|
166
|
+
source: asciisourcerer
|
|
167
|
+
description: |
|
|
168
|
+
Convert a string into a lowercase URL "slug".
|
|
169
|
+
|
|
170
|
+
NOTE: This is not the Jekyll version.
|
|
171
|
+
kind: string-conversion
|
|
172
|
+
examples:
|
|
173
|
+
- input: '{{ "The _config.yml file" | slugify }}'
|
|
174
|
+
output: 'the-config-yml-file'
|
|
175
|
+
- input: '{{ "The _config.yml file" | slugify: "_" }}'
|
|
176
|
+
output: 'the_config_yml_file'
|
|
177
|
+
|
|
178
|
+
# - key: to_slug
|
|
179
|
+
# name: String to Slug
|
|
180
|
+
# source: sterile
|
|
181
|
+
# description: Simple slug converter.
|
|
182
|
+
# group: string-conversion
|
|
183
|
+
|
|
184
|
+
- key: jsonify
|
|
185
|
+
name: Data To JSON
|
|
186
|
+
source: jekyll
|
|
187
|
+
description: Convert Hash or Array to JSON.
|
|
188
|
+
kind: object-conversion
|
|
189
|
+
examples:
|
|
190
|
+
- input: '{{ tags_array | jsonify }}'
|
|
191
|
+
output: '["foo","bar","baz"]'
|
|
192
|
+
|
|
193
|
+
- key: normalize_whitespace
|
|
194
|
+
name: Normalize Whitespace
|
|
195
|
+
source: jekyll
|
|
196
|
+
description: Replace any occurrence of whitespace with a single space.
|
|
197
|
+
kind: string-conversion
|
|
198
|
+
examples:
|
|
199
|
+
- input: '{{ "a b" | normalize_whitespace }}'
|
|
200
|
+
output: 'a b'
|
|
201
|
+
|
|
202
|
+
- key: sort
|
|
203
|
+
name: Sort
|
|
204
|
+
source: jekyll
|
|
205
|
+
description: |
|
|
206
|
+
Sort an array. Optional arguments for hashes
|
|
207
|
+
1. property name
|
|
208
|
+
2. nils order (_first_ or _last_).
|
|
209
|
+
tags: [array]
|
|
210
|
+
kind: array-organizing
|
|
211
|
+
examples:
|
|
212
|
+
- input: '{{ page.tags | sort | inspect }}'
|
|
213
|
+
output: '["Seattle", "Spokane", "Tacoma"]'
|
|
214
|
+
- input: '{{ site.posts | sort: "author" }}'
|
|
215
|
+
returns: An array of hashes, alphabetized by the value of the `author` property
|
|
216
|
+
test: false
|
|
217
|
+
- input: '{{ site.pages | sort: "title", "last" }}'
|
|
218
|
+
returns: An array of hashes, alphabetized by the `title` property's values, with items lacking titles (nil) at the end
|
|
219
|
+
test: false
|
|
220
|
+
|
|
221
|
+
- key: sample
|
|
222
|
+
name: Sample
|
|
223
|
+
source: jekyll
|
|
224
|
+
description: 'Pick a random value from an array. Optionally, pick multiple values.'
|
|
225
|
+
tags: [array]
|
|
226
|
+
kind: array-select
|
|
227
|
+
examples:
|
|
228
|
+
- input: '{{ site.pages | sample }}'
|
|
229
|
+
returns: An array containing one randomly chosen item.
|
|
230
|
+
test: false
|
|
231
|
+
- input: '{{ site.pages | sample: 2 }}'
|
|
232
|
+
returns: An array containing two randomly chosen array items.
|
|
233
|
+
test: false
|
|
234
|
+
|
|
235
|
+
- key: to_integer
|
|
236
|
+
name: To Integer
|
|
237
|
+
source: jekyll
|
|
238
|
+
description: Convert a string or boolean to integer.
|
|
239
|
+
tags: [string, conversion, math]
|
|
240
|
+
kind: object-conversion
|
|
241
|
+
examples:
|
|
242
|
+
- input: '{{ true | to_integer }}'
|
|
243
|
+
output: 1
|
|
244
|
+
- output: Samesies!
|
|
245
|
+
input: |
|
|
246
|
+
{% assign five = "5" | to_integer %}
|
|
247
|
+
{% if five == 5 %}Samesies!{% endif %}
|
|
248
|
+
- input: '{{ "five" | to_integer }}'
|
|
249
|
+
output: 0
|
|
250
|
+
|
|
251
|
+
- key: push
|
|
252
|
+
name: Push
|
|
253
|
+
source: jekyll
|
|
254
|
+
description: |
|
|
255
|
+
Insert an item at the end of an array
|
|
256
|
+
tags: [array]
|
|
257
|
+
kind: array-management
|
|
258
|
+
examples:
|
|
259
|
+
- input: '{{ page.tags | push: "Spokane" | inspect }}'
|
|
260
|
+
output: '["Seattle", "Tacoma", "Spokane", "Spokane"]'
|
|
261
|
+
|
|
262
|
+
- key: pop
|
|
263
|
+
name: Pop
|
|
264
|
+
source: jekyll
|
|
265
|
+
description: |
|
|
266
|
+
Remove an item from the end of an array
|
|
267
|
+
tags: [array]
|
|
268
|
+
kind: array-management
|
|
269
|
+
examples:
|
|
270
|
+
- input: '{{ page.tags | pop | inspect }}'
|
|
271
|
+
output: '["Seattle", "Tacoma"]'
|
|
272
|
+
|
|
273
|
+
- key: shift
|
|
274
|
+
name: Shift
|
|
275
|
+
source: jekyll
|
|
276
|
+
description: |
|
|
277
|
+
Remove an item from the beginning of an array
|
|
278
|
+
tags: [array]
|
|
279
|
+
kind: array-management
|
|
280
|
+
examples:
|
|
281
|
+
- input: '{{ page.tags | shift | inspect }}'
|
|
282
|
+
output: '["Tacoma", "Spokane"]'
|
|
283
|
+
|
|
284
|
+
- key: unshift
|
|
285
|
+
name: Unshift
|
|
286
|
+
source: jekyll
|
|
287
|
+
description: |
|
|
288
|
+
Insert an item at the beginning of an array
|
|
289
|
+
tags: [array]
|
|
290
|
+
kind: array-management
|
|
291
|
+
examples:
|
|
292
|
+
- input: '{{ page.tags | unshift: "Olympia" | inspect }}'
|
|
293
|
+
output: '["Olympia", "Seattle", "Tacoma", "Spokane"]'
|
|
294
|
+
|
|
295
|
+
- key: inspect
|
|
296
|
+
name: Inspect
|
|
297
|
+
source: asciisourcerer
|
|
298
|
+
description: |
|
|
299
|
+
Convert an object into its String representation for debugging.
|
|
300
|
+
Overrides Jekyll's `inspect` filter, adding an optional `format` argument:
|
|
301
|
+
`html` (default) reproduces Jekyll's own behavior exactly (an HTML-escaped
|
|
302
|
+
`Object#inspect` string, quotes become `"`); `yaml` and `json` render
|
|
303
|
+
the object in those formats instead.
|
|
304
|
+
tags: [conversion]
|
|
305
|
+
kind: object-analysis
|
|
306
|
+
examples:
|
|
307
|
+
- input: '{{ tags_array | inspect }}'
|
|
308
|
+
output: '["foo", "bar", "baz"]'
|
|
309
|
+
description: Default (html) format, matches Jekyll's inspect
|
|
310
|
+
- input: |
|
|
311
|
+
{{ tags_array | inspect: "yaml" }}
|
|
312
|
+
output: |
|
|
313
|
+
---
|
|
314
|
+
- foo
|
|
315
|
+
- bar
|
|
316
|
+
- baz
|
|
317
|
+
description: YAML format
|
|
318
|
+
- input: '{{ tags_array | inspect: "json" }}'
|
|
319
|
+
output: '["foo","bar","baz"]'
|
|
320
|
+
description: JSON format
|
|
321
|
+
|
|
322
|
+
- key: abs
|
|
323
|
+
name: Absolute Value
|
|
324
|
+
source: shopify
|
|
325
|
+
description: Returns the absolute value of a number.
|
|
326
|
+
tags: [math]
|
|
327
|
+
kind: math
|
|
328
|
+
examples:
|
|
329
|
+
- input: '{{ -17 | abs }}'
|
|
330
|
+
output: '17'
|
|
331
|
+
- input: '{{ "-19.86" | abs }}'
|
|
332
|
+
output: '19.86'
|
|
333
|
+
|
|
334
|
+
- key: append
|
|
335
|
+
name: Append
|
|
336
|
+
source: shopify
|
|
337
|
+
description: Adds the specified string to the end of another string.
|
|
338
|
+
kind: string-management
|
|
339
|
+
examples:
|
|
340
|
+
- input: '{{ "/my/fancy/url" | append: ".html" }}'
|
|
341
|
+
output: '/my/fancy/url.html'
|
|
342
|
+
|
|
343
|
+
- key: at_least
|
|
344
|
+
name: At Least
|
|
345
|
+
source: shopify
|
|
346
|
+
description: Limits a number to a minimum value; returns the input unchanged if it's already at or above the minimum.
|
|
347
|
+
tags: [math]
|
|
348
|
+
kind: math
|
|
349
|
+
examples:
|
|
350
|
+
- input: '{{ 4 | at_least: 5 }}'
|
|
351
|
+
output: '5'
|
|
352
|
+
- input: '{{ 4 | at_least: 3 }}'
|
|
353
|
+
output: '4'
|
|
354
|
+
|
|
355
|
+
- key: at_most
|
|
356
|
+
name: At Most
|
|
357
|
+
source: shopify
|
|
358
|
+
description: Limits a number to a maximum value; returns the input unchanged if it's already at or below the maximum.
|
|
359
|
+
tags: [math]
|
|
360
|
+
kind: math
|
|
361
|
+
examples:
|
|
362
|
+
- input: '{{ 4 | at_most: 5 }}'
|
|
363
|
+
output: '4'
|
|
364
|
+
- input: '{{ 4 | at_most: 3 }}'
|
|
365
|
+
output: '3'
|
|
366
|
+
|
|
367
|
+
- key: sum
|
|
368
|
+
name: Sum
|
|
369
|
+
source: asciisourcerer
|
|
370
|
+
description: |
|
|
371
|
+
Sums a numeric array, or an array of Hashes at the given property.
|
|
372
|
+
|
|
373
|
+
(This filter duplicates Shopify's `sum` filter.)
|
|
374
|
+
tags: [math, array]
|
|
375
|
+
kind: math
|
|
376
|
+
examples:
|
|
377
|
+
- input: '{{ data.members | sum: "grad_year" }}'
|
|
378
|
+
output: '6040'
|
|
379
|
+
|
|
380
|
+
- key: capitalize
|
|
381
|
+
name: Capitalize
|
|
382
|
+
source: shopify
|
|
383
|
+
description: Capitalizes the first character of a string and downcases the rest. Only the first character is affected, so later words are not capitalized.
|
|
384
|
+
kind: string-conversion
|
|
385
|
+
examples:
|
|
386
|
+
- input: '{{ "my GREAT title" | capitalize }}'
|
|
387
|
+
output: 'My great title'
|
|
388
|
+
|
|
389
|
+
- key: ceil
|
|
390
|
+
name: Ceiling
|
|
391
|
+
source: shopify
|
|
392
|
+
description: Rounds a number up to the nearest whole number. Liquid tries to convert the input to a number before applying the filter.
|
|
393
|
+
tags: [math]
|
|
394
|
+
kind: math
|
|
395
|
+
examples:
|
|
396
|
+
- input: '{{ 1.2 | ceil }}'
|
|
397
|
+
output: '2'
|
|
398
|
+
|
|
399
|
+
- key: compact
|
|
400
|
+
name: Compact
|
|
401
|
+
source: shopify
|
|
402
|
+
description: Removes any `nil` values from an array.
|
|
403
|
+
tags: [array]
|
|
404
|
+
kind: array-management
|
|
405
|
+
examples:
|
|
406
|
+
- input: |
|
|
407
|
+
{% assign compacted = mixed_array | compact %}
|
|
408
|
+
{{ compacted | join: "," }}
|
|
409
|
+
output: 'a,b,c'
|
|
410
|
+
|
|
411
|
+
- key: concat
|
|
412
|
+
name: Concatenate
|
|
413
|
+
source: shopify
|
|
414
|
+
description: Concatenates (joins together) multiple arrays. The resulting array contains all the items from the input arrays.
|
|
415
|
+
tags: [array]
|
|
416
|
+
kind: array-management
|
|
417
|
+
examples:
|
|
418
|
+
- input: |
|
|
419
|
+
{% assign fruits = "apples, oranges" | split: ", " %}
|
|
420
|
+
{% assign veggies = "carrots, turnips" | split: ", " %}
|
|
421
|
+
{{ fruits | concat: veggies | join: "," }}
|
|
422
|
+
output: 'apples,oranges,carrots,turnips'
|
|
423
|
+
|
|
424
|
+
- key: date
|
|
425
|
+
name: Date Format
|
|
426
|
+
source: shopify
|
|
427
|
+
description: |
|
|
428
|
+
Converts a timestamp into another date format, using the same format
|
|
429
|
+
syntax as `strftime`.
|
|
430
|
+
tags: [string, date]
|
|
431
|
+
kind: date-format
|
|
432
|
+
examples:
|
|
433
|
+
- input: '{{ data.time | date: "%Y-%m-%d" }}'
|
|
434
|
+
output: '2008-11-07'
|
|
435
|
+
|
|
436
|
+
- key: default
|
|
437
|
+
name: Default
|
|
438
|
+
source: shopify
|
|
439
|
+
description: |
|
|
440
|
+
Sets a fallback value for a variable that is `nil`, `false`, or empty.
|
|
441
|
+
Has no effect if the input already has a value.
|
|
442
|
+
tags: [variable]
|
|
443
|
+
kind: variable
|
|
444
|
+
examples:
|
|
445
|
+
- input: '{{ nonexistent_var | default: "fallback" }}'
|
|
446
|
+
output: 'fallback'
|
|
447
|
+
|
|
448
|
+
- key: divided_by
|
|
449
|
+
name: Divided By
|
|
450
|
+
source: shopify
|
|
451
|
+
description: |
|
|
452
|
+
Divides a number by another number. The result's type matches the
|
|
453
|
+
divisor's: dividing by an integer floors to an integer, dividing by a
|
|
454
|
+
float returns a float.
|
|
455
|
+
tags: [math]
|
|
456
|
+
kind: math
|
|
457
|
+
examples:
|
|
458
|
+
- input: '{{ 16 | divided_by: 4 }}'
|
|
459
|
+
output: '4'
|
|
460
|
+
- input: '{{ 20 | divided_by: 7 }}'
|
|
461
|
+
output: '2'
|
|
462
|
+
- input: '{{ 20 | divided_by: 7.0 }}'
|
|
463
|
+
output: '2.857142857142857'
|
|
464
|
+
|
|
465
|
+
- key: downcase
|
|
466
|
+
name: Downcase
|
|
467
|
+
source: shopify
|
|
468
|
+
description: Makes each character in a string lowercase.
|
|
469
|
+
kind: string-conversion
|
|
470
|
+
examples:
|
|
471
|
+
- input: '{{ "Parker Moore" | downcase }}'
|
|
472
|
+
output: 'parker moore'
|
|
473
|
+
|
|
474
|
+
- key: escape
|
|
475
|
+
name: Escape
|
|
476
|
+
source: shopify
|
|
477
|
+
description: Escapes a string's HTML-unsafe characters (so it can safely be embedded in HTML markup).
|
|
478
|
+
kind: string-conversion
|
|
479
|
+
examples:
|
|
480
|
+
- input: "{{ \"Have you read 'James & the Giant Peach'?\" | escape }}"
|
|
481
|
+
output: 'Have you read 'James & the Giant Peach'?'
|
|
482
|
+
|
|
483
|
+
- key: escape_once
|
|
484
|
+
name: Escape Once
|
|
485
|
+
source: shopify
|
|
486
|
+
description: Escapes a string's HTML-unsafe characters without double-escaping entities that are already escaped.
|
|
487
|
+
kind: string-conversion
|
|
488
|
+
examples:
|
|
489
|
+
- input: '{{ "1 < 2 & 3" | escape_once }}'
|
|
490
|
+
output: '1 < 2 & 3'
|
|
491
|
+
- input: '{{ "1 < 2 & 3" | escape_once }}'
|
|
492
|
+
output: '1 < 2 & 3'
|
|
493
|
+
|
|
494
|
+
- key: first
|
|
495
|
+
name: First
|
|
496
|
+
source: shopify
|
|
497
|
+
description: Returns the first item of an array.
|
|
498
|
+
tags: [array]
|
|
499
|
+
kind: array-select
|
|
500
|
+
examples:
|
|
501
|
+
- input: '{{ "Ground control to Major Tom." | split: " " | first }}'
|
|
502
|
+
output: 'Ground'
|
|
503
|
+
|
|
504
|
+
- key: floor
|
|
505
|
+
name: Floor
|
|
506
|
+
source: shopify
|
|
507
|
+
description: Rounds a number down to the nearest whole number. Liquid tries to convert the input to a number before applying the filter.
|
|
508
|
+
tags: [math]
|
|
509
|
+
kind: math
|
|
510
|
+
examples:
|
|
511
|
+
- input: '{{ 1.2 | floor }}'
|
|
512
|
+
output: '1'
|
|
513
|
+
|
|
514
|
+
- key: join
|
|
515
|
+
name: Join
|
|
516
|
+
source: shopify
|
|
517
|
+
description: Combines the items in an array into a single string, using the argument as a separator.
|
|
518
|
+
tags: [array, conversion]
|
|
519
|
+
kind: object-conversion
|
|
520
|
+
examples:
|
|
521
|
+
- input: |
|
|
522
|
+
{% assign beatles = "John, Paul, George, Ringo" | split: ", " %}
|
|
523
|
+
{{ beatles | join: " and " }}
|
|
524
|
+
output: 'John and Paul and George and Ringo'
|
|
525
|
+
|
|
526
|
+
- key: last
|
|
527
|
+
name: Last
|
|
528
|
+
source: shopify
|
|
529
|
+
description: Returns the last item of an array.
|
|
530
|
+
tags: [array]
|
|
531
|
+
kind: array-select
|
|
532
|
+
examples:
|
|
533
|
+
- input: '{{ "Ground control to Major Tom." | split: " " | last }}'
|
|
534
|
+
output: 'Tom.'
|
|
535
|
+
|
|
536
|
+
- key: lstrip
|
|
537
|
+
name: Left Strip
|
|
538
|
+
source: shopify
|
|
539
|
+
description: |
|
|
540
|
+
Removes whitespace (tabs, spaces, newlines) from the left side of a
|
|
541
|
+
string. Does not affect spaces between words.
|
|
542
|
+
kind: string-management
|
|
543
|
+
examples:
|
|
544
|
+
- input: '{{ " So much room " | lstrip }}!'
|
|
545
|
+
output: 'So much room !'
|
|
546
|
+
|
|
547
|
+
- key: map
|
|
548
|
+
name: Map
|
|
549
|
+
source: shopify
|
|
550
|
+
description: Creates an array of values by extracting the values of a named property from an array of objects.
|
|
551
|
+
tags: [array, conversion]
|
|
552
|
+
kind: object-conversion
|
|
553
|
+
examples:
|
|
554
|
+
- input: |
|
|
555
|
+
{{ data.members | map: "user" | join: "," }}
|
|
556
|
+
output: 'andie,lonnie,cindy'
|
|
557
|
+
|
|
558
|
+
- key: minus
|
|
559
|
+
name: Minus (subtract)
|
|
560
|
+
source: shopify
|
|
561
|
+
description: Subtracts a number from another number.
|
|
562
|
+
tags: [math]
|
|
563
|
+
kind: math
|
|
564
|
+
examples:
|
|
565
|
+
- input: '{{ 4 | minus: 2 }}'
|
|
566
|
+
output: '2'
|
|
567
|
+
- input: '{{ 16 | minus: 4 }}'
|
|
568
|
+
output: '12'
|
|
569
|
+
|
|
570
|
+
- key: modulo
|
|
571
|
+
name: Modulo
|
|
572
|
+
source: shopify
|
|
573
|
+
description: Returns the remainder of a division operation.
|
|
574
|
+
tags: [math]
|
|
575
|
+
kind: math
|
|
576
|
+
examples:
|
|
577
|
+
- input: '{{ 3 | modulo: 2 }}'
|
|
578
|
+
output: '1'
|
|
579
|
+
- input: '{{ 24 | modulo: 7 }}'
|
|
580
|
+
output: '3'
|
|
581
|
+
|
|
582
|
+
- key: newline_to_br
|
|
583
|
+
name: Newline to Break Tag
|
|
584
|
+
source: shopify
|
|
585
|
+
description: Inserts an HTML line break (`<br />`) in front of each newline in a string.
|
|
586
|
+
kind: string-conversion
|
|
587
|
+
examples:
|
|
588
|
+
- input: |
|
|
589
|
+
{% capture s %}Hello
|
|
590
|
+
there{% endcapture %}{{ s | newline_to_br }}
|
|
591
|
+
output: "Hello<br />\nthere"
|
|
592
|
+
|
|
593
|
+
- key: plus
|
|
594
|
+
name: Plus (add)
|
|
595
|
+
source: shopify
|
|
596
|
+
description: Adds a number to another number.
|
|
597
|
+
tags: [math]
|
|
598
|
+
kind: math
|
|
599
|
+
examples:
|
|
600
|
+
- input: '{{ 4 | plus: 2 }}'
|
|
601
|
+
output: '6'
|
|
602
|
+
|
|
603
|
+
- key: prepend
|
|
604
|
+
name: Prepend
|
|
605
|
+
source: shopify
|
|
606
|
+
description: Adds the specified string to the beginning of another string.
|
|
607
|
+
kind: string-management
|
|
608
|
+
examples:
|
|
609
|
+
- input: '{{ "apples, oranges, and bananas" | prepend: "Some fruit: " }}'
|
|
610
|
+
output: 'Some fruit: apples, oranges, and bananas'
|
|
611
|
+
|
|
612
|
+
- key: remove
|
|
613
|
+
name: Remove
|
|
614
|
+
source: shopify
|
|
615
|
+
description: Removes every occurrence of the specified substring from a string.
|
|
616
|
+
kind: string-conversion
|
|
617
|
+
examples:
|
|
618
|
+
- input: '{{ "I strained to see the train through the rain" | remove: "rain" }}'
|
|
619
|
+
output: 'I sted to see the t through the '
|
|
620
|
+
|
|
621
|
+
- key: remove_first
|
|
622
|
+
name: Remove First
|
|
623
|
+
source: shopify
|
|
624
|
+
description: Removes only the first occurrence of the specified substring from a string.
|
|
625
|
+
kind: string-conversion
|
|
626
|
+
examples:
|
|
627
|
+
- input: '{{ "I strained to see the train through the rain" | remove_first: "rain" }}'
|
|
628
|
+
output: 'I sted to see the train through the rain'
|
|
629
|
+
|
|
630
|
+
- key: remove_last
|
|
631
|
+
name: Remove Last
|
|
632
|
+
source: asciisourcerer
|
|
633
|
+
description: |
|
|
634
|
+
Removes the last instance of a substring from a string.
|
|
635
|
+
|
|
636
|
+
(This filter duplicates Shopify's `remove_last` filter.)
|
|
637
|
+
kind: string-conversion
|
|
638
|
+
examples:
|
|
639
|
+
- input: '{{ "Ground control to Major Tom." | remove_last: "o" }}'
|
|
640
|
+
output: 'Ground control to Major Tm.'
|
|
641
|
+
|
|
642
|
+
- key: replace
|
|
643
|
+
name: Replace
|
|
644
|
+
source: shopify
|
|
645
|
+
description: Replaces every occurrence of the first argument in a string with the second argument.
|
|
646
|
+
kind: string-conversion
|
|
647
|
+
examples:
|
|
648
|
+
- input: '{{ "Take my protein pills and put my helmet on" | replace: "my", "your" }}'
|
|
649
|
+
output: 'Take your protein pills and put your helmet on'
|
|
650
|
+
|
|
651
|
+
- key: replace_first
|
|
652
|
+
name: Replace First
|
|
653
|
+
source: shopify
|
|
654
|
+
description: Replaces only the first occurrence of the first argument in a string with the second argument.
|
|
655
|
+
kind: string-conversion
|
|
656
|
+
examples:
|
|
657
|
+
- input: '{{ "Take my protein pills and put my helmet on" | replace_first: "my", "your" }}'
|
|
658
|
+
output: 'Take your protein pills and put my helmet on'
|
|
659
|
+
|
|
660
|
+
- key: replace_last
|
|
661
|
+
name: Replace Last
|
|
662
|
+
source: asciisourcerer
|
|
663
|
+
description: |
|
|
664
|
+
Replaces the last instance of a substring in a string with a replacement.
|
|
665
|
+
|
|
666
|
+
(This filter duplicates Shopify's `replace_last` filter.)
|
|
667
|
+
|
|
668
|
+
kind: string-conversion
|
|
669
|
+
examples:
|
|
670
|
+
- input: '{{ "Ground control to Major Tom." | replace_last: "o", "0" }}'
|
|
671
|
+
output: 'Ground control to Major T0m.'
|
|
672
|
+
|
|
673
|
+
- key: squish
|
|
674
|
+
name: Squish
|
|
675
|
+
source: asciisourcerer
|
|
676
|
+
description: |
|
|
677
|
+
Strips leading and trailing whitespace and collapses interior runs of
|
|
678
|
+
whitespace to a single space.
|
|
679
|
+
|
|
680
|
+
(This filter duplicates Liquid 5's `squish` filter.)
|
|
681
|
+
kind: string-conversion
|
|
682
|
+
examples:
|
|
683
|
+
- input: '{{ " A string that is obviously longer than 25 characters " | squish }}'
|
|
684
|
+
output: 'A string that is obviously longer than 25 characters'
|
|
685
|
+
|
|
686
|
+
- key: reverse
|
|
687
|
+
name: Reverse
|
|
688
|
+
source: shopify
|
|
689
|
+
description: |
|
|
690
|
+
Reverses the order of the items in an array. Cannot reverse a string
|
|
691
|
+
directly; split it into an array first.
|
|
692
|
+
tags: [array]
|
|
693
|
+
kind: array-organizing
|
|
694
|
+
examples:
|
|
695
|
+
- input: |
|
|
696
|
+
{% assign arr = "apples, oranges, peaches, plums" | split: ", " %}
|
|
697
|
+
{{ arr | reverse | join: ", " }}
|
|
698
|
+
output: 'plums, peaches, oranges, apples'
|
|
699
|
+
|
|
700
|
+
- key: round
|
|
701
|
+
name: Round
|
|
702
|
+
source: shopify
|
|
703
|
+
description: Rounds a number to the nearest integer, or to a given number of decimal places if an argument is passed.
|
|
704
|
+
tags: [math]
|
|
705
|
+
kind: math
|
|
706
|
+
examples:
|
|
707
|
+
- input: '{{ 1.2 | round }}'
|
|
708
|
+
output: '1'
|
|
709
|
+
- input: '{{ 2.7 | round }}'
|
|
710
|
+
output: '3'
|
|
711
|
+
- input: '{{ 183.357 | round: 2 }}'
|
|
712
|
+
output: '183.36'
|
|
713
|
+
|
|
714
|
+
- key: rstrip
|
|
715
|
+
name: Right Strip
|
|
716
|
+
source: shopify
|
|
717
|
+
description: |
|
|
718
|
+
Removes whitespace (tabs, spaces, newlines) from the right side of a
|
|
719
|
+
string. Does not affect spaces between words.
|
|
720
|
+
kind: string-conversion
|
|
721
|
+
examples:
|
|
722
|
+
- input: '{{ " So much room " | rstrip }}!'
|
|
723
|
+
output: ' So much room!'
|
|
724
|
+
|
|
725
|
+
- key: size
|
|
726
|
+
name: Size
|
|
727
|
+
source: shopify
|
|
728
|
+
description: Returns the number of characters in a string, or the number of items in an array.
|
|
729
|
+
tags: [string, array]
|
|
730
|
+
kind: object-analysis
|
|
731
|
+
examples:
|
|
732
|
+
- input: '{{ "Ground control to Major Tom." | size }}'
|
|
733
|
+
output: '28'
|
|
734
|
+
|
|
735
|
+
- key: slice
|
|
736
|
+
name: Slice
|
|
737
|
+
source: shopify
|
|
738
|
+
description: |
|
|
739
|
+
Returns a substring or array slice, starting at the index given by the
|
|
740
|
+
first argument. An optional second argument gives the length. Negative
|
|
741
|
+
indices count from the end.
|
|
742
|
+
tags: [string, array, conversion]
|
|
743
|
+
kind: object-conversion
|
|
744
|
+
examples:
|
|
745
|
+
- input: '{{ "Liquid" | slice: 0 }}'
|
|
746
|
+
output: 'L'
|
|
747
|
+
- input: '{{ "Liquid" | slice: 2, 3 }}'
|
|
748
|
+
output: 'qui'
|
|
749
|
+
- input: '{{ "Liquid" | slice: -3, 2 }}'
|
|
750
|
+
output: 'ui'
|
|
751
|
+
|
|
752
|
+
- key: split
|
|
753
|
+
name: Split
|
|
754
|
+
source: shopify
|
|
755
|
+
description: |
|
|
756
|
+
Divides a string into an array using the argument as a separator.
|
|
757
|
+
Commonly used to convert delimited text into an array.
|
|
758
|
+
tags: [string, array, conversion]
|
|
759
|
+
kind: object-conversion
|
|
760
|
+
examples:
|
|
761
|
+
- input: |
|
|
762
|
+
{% assign beatles = "John, Paul, George, Ringo" | split: ", " %}
|
|
763
|
+
{{ beatles | join: "|" }}
|
|
764
|
+
output: 'John|Paul|George|Ringo'
|
|
765
|
+
|
|
766
|
+
- key: strip
|
|
767
|
+
name: Strip
|
|
768
|
+
source: shopify
|
|
769
|
+
description: |
|
|
770
|
+
Removes whitespace (tabs, spaces, newlines) from both sides of a
|
|
771
|
+
string. Does not affect spaces between words.
|
|
772
|
+
kind: string-conversion
|
|
773
|
+
examples:
|
|
774
|
+
- input: '{{ " So much room " | strip }}!'
|
|
775
|
+
output: 'So much room!'
|
|
776
|
+
|
|
777
|
+
- key: strip_html
|
|
778
|
+
name: Strip HTML
|
|
779
|
+
source: shopify
|
|
780
|
+
description: Removes any HTML tags from a string.
|
|
781
|
+
kind: string-conversion
|
|
782
|
+
examples:
|
|
783
|
+
- input: '{{ "Have <em>you</em> read <strong>Ulysses</strong>?" | strip_html }}'
|
|
784
|
+
output: 'Have you read Ulysses?'
|
|
785
|
+
|
|
786
|
+
- key: strip_newlines
|
|
787
|
+
name: Strip Newlines
|
|
788
|
+
source: shopify
|
|
789
|
+
description: Removes any newline characters from a string.
|
|
790
|
+
kind: string-conversion
|
|
791
|
+
examples:
|
|
792
|
+
- input: |
|
|
793
|
+
{% capture s %}Hello
|
|
794
|
+
there{% endcapture %}{{ s | strip_newlines }}
|
|
795
|
+
output: 'Hellothere'
|
|
796
|
+
|
|
797
|
+
- key: times
|
|
798
|
+
name: Times (multiply)
|
|
799
|
+
source: shopify
|
|
800
|
+
description: Multiplies a number by another number.
|
|
801
|
+
tags: [math]
|
|
802
|
+
kind: math
|
|
803
|
+
examples:
|
|
804
|
+
- input: '{{ 3 | times: 2 }}'
|
|
805
|
+
output: '6'
|
|
806
|
+
|
|
807
|
+
- key: truncate
|
|
808
|
+
name: Truncate
|
|
809
|
+
source: shopify
|
|
810
|
+
description: |
|
|
811
|
+
Shortens a string to the given number of characters. If shortened, an
|
|
812
|
+
ellipsis (`...`) is appended and counts against the total; pass a
|
|
813
|
+
second argument to use a different (or no) ellipsis.
|
|
814
|
+
kind: string-management
|
|
815
|
+
examples:
|
|
816
|
+
- input: '{{ "Ground control to Major Tom." | truncate: 20 }}'
|
|
817
|
+
output: 'Ground control to...'
|
|
818
|
+
- input: '{{ "Ground control to Major Tom." | truncate: 25, ", and so on" }}'
|
|
819
|
+
output: 'Ground control, and so on'
|
|
820
|
+
|
|
821
|
+
- key: truncatewords
|
|
822
|
+
name: Truncate Words
|
|
823
|
+
source: shopify
|
|
824
|
+
description: |
|
|
825
|
+
Shortens a string to the given number of words. If shortened, an
|
|
826
|
+
ellipsis (`...`) is appended; pass a second argument to use a
|
|
827
|
+
different (or no) ellipsis.
|
|
828
|
+
kind: string-conversion
|
|
829
|
+
examples:
|
|
830
|
+
- input: '{{ "Ground control to Major Tom." | truncatewords: 3 }}'
|
|
831
|
+
output: 'Ground control to...'
|
|
832
|
+
|
|
833
|
+
- key: uniq
|
|
834
|
+
name: Uniq
|
|
835
|
+
source: shopify
|
|
836
|
+
description: Removes any duplicate items from an array, preserving the first occurrence's order.
|
|
837
|
+
tags: [array]
|
|
838
|
+
kind: array-management
|
|
839
|
+
examples:
|
|
840
|
+
- input: |
|
|
841
|
+
{% assign arr = "ants, bugs, bees, bugs, ants" | split: ", " %}
|
|
842
|
+
{{ arr | uniq | join: "," }}
|
|
843
|
+
output: 'ants,bugs,bees'
|
|
844
|
+
|
|
845
|
+
- key: upcase
|
|
846
|
+
name: Upcase
|
|
847
|
+
source: shopify
|
|
848
|
+
description: Makes each character in a string uppercase.
|
|
849
|
+
kind: string-conversion
|
|
850
|
+
examples:
|
|
851
|
+
- input: '{{ "Parker Moore" | upcase }}'
|
|
852
|
+
output: 'PARKER MOORE'
|
|
853
|
+
|
|
854
|
+
- key: url_decode
|
|
855
|
+
name: URL Decode
|
|
856
|
+
source: shopify
|
|
857
|
+
description: Decodes a string that has been encoded as a URL, or by `url_encode`.
|
|
858
|
+
kind: string-recode
|
|
859
|
+
examples:
|
|
860
|
+
- input: '{{ "%27Stop%21%27+said+Fred" | url_decode }}'
|
|
861
|
+
output: "'Stop!' said Fred"
|
|
862
|
+
|
|
863
|
+
- key: url_encode
|
|
864
|
+
name: URL Encode
|
|
865
|
+
source: shopify
|
|
866
|
+
description: |
|
|
867
|
+
Converts any URL-unsafe characters in a string into percent-encoded
|
|
868
|
+
characters. A space becomes a `+` rather than a percent-encoded
|
|
869
|
+
character.
|
|
870
|
+
kind: string-recode
|
|
871
|
+
examples:
|
|
872
|
+
- input: '{{ "john@liquid.com" | url_encode }}'
|
|
873
|
+
output: 'john%40liquid.com'
|
|
874
|
+
- input: '{{ "Tetsuro Takara" | url_encode }}'
|
|
875
|
+
output: 'Tetsuro+Takara'
|
|
876
|
+
|
|
877
|
+
- key: sgyml_type
|
|
878
|
+
name: SGYML Type
|
|
879
|
+
source: schemagraphy
|
|
880
|
+
kind: data-type
|
|
881
|
+
|
|
882
|
+
|
|
883
|
+
- key: wrap
|
|
884
|
+
name: Wrap
|
|
885
|
+
source: asciisourcerer
|
|
886
|
+
kind: string-conversion
|
|
887
|
+
examples:
|
|
888
|
+
- input: '{{ "A string that is obviously longer than 25 characters" | wrap: 25 }}'
|
|
889
|
+
output: |
|
|
890
|
+
A string that is
|
|
891
|
+
obviously longer than 25
|
|
892
|
+
characters
|
|
893
|
+
|
|
894
|
+
- key: commentwrap
|
|
895
|
+
name: Comment Wrap
|
|
896
|
+
source: asciisourcerer
|
|
897
|
+
kind: string-conversion
|
|
898
|
+
examples:
|
|
899
|
+
- input: '{{ comment_text | commentwrap: 25, "// " }}'
|
|
900
|
+
output: |
|
|
901
|
+
// A string that is
|
|
902
|
+
// obviously longer than 25
|
|
903
|
+
// characters
|
|
904
|
+
- input: '{{ comment_text | commentwrap: 25, "xml" }}'
|
|
905
|
+
output: |
|
|
906
|
+
<!-- A string that is
|
|
907
|
+
obviously longer than 25
|
|
908
|
+
characters -->
|
|
909
|
+
- input: '{{ comment_text | commentwrap: 25, "/*|*/" }}'
|
|
910
|
+
output: |
|
|
911
|
+
/* A string that is
|
|
912
|
+
obviously longer than 25
|
|
913
|
+
characters
|
|
914
|
+
*/
|
|
915
|
+
|
|
916
|
+
- key: to_cli_args
|
|
917
|
+
name: Convert to CLI Arguments
|
|
918
|
+
source: asciisourcerer
|
|
919
|
+
kind: object-conversion
|
|
920
|
+
description: |
|
|
921
|
+
Transform a Hash into a string of CLI-formatted arguments.
|
|
922
|
+
Accepts an optional template name to format the output.
|
|
923
|
+
See `parameters` section for all available templates and their output formats.
|
|
924
|
+
When no template is specified, defaults to `long_space` format.
|
|
925
|
+
Arguments are joined with a space by default; can be customized via delimiter parameter.
|
|
926
|
+
parameters:
|
|
927
|
+
short_flag: '-<o>'
|
|
928
|
+
long_flag: '--<option>'
|
|
929
|
+
go_flag: '-<option>'
|
|
930
|
+
short_space: '-<o> <argument>'
|
|
931
|
+
long_space: '--<option> <argument>'
|
|
932
|
+
short_equals: '-<o>=<argument>'
|
|
933
|
+
long_equals: '--<option>=<argument>'
|
|
934
|
+
short_keyval: '-<o> <key>=<value>'
|
|
935
|
+
long_keyval: '--<option> <key>=<value>'
|
|
936
|
+
positional: '<argument>'
|
|
937
|
+
keyval: '<option>=<argument>'
|
|
938
|
+
attached: '-<o><argument>'
|
|
939
|
+
env_arg: '<VARIABLE>=<value>'
|
|
940
|
+
examples:
|
|
941
|
+
- input: '{{ my_flat_hash | to_cli_args }}'
|
|
942
|
+
output: '--key1 valuu_one --key2 val_two --key3 third value'
|
|
943
|
+
description: Default (long_space) format
|
|
944
|
+
- input: '{{ my_flat_hash | to_cli_args: "long_equals" }}'
|
|
945
|
+
output: '--key1=valuu_one --key2=val_two --key3=third value'
|
|
946
|
+
description: Long equals format
|
|
947
|
+
- input: '{{ cli_flags_hash | to_cli_args: "short_space" }}'
|
|
948
|
+
output: '-k valuu_one -v val_two -o third value'
|
|
949
|
+
description: Single-letter flags with values
|
|
950
|
+
- input: '{{ my_flat_hash | to_cli_args: "positional" }}'
|
|
951
|
+
output: 'valuu_one val_two third value'
|
|
952
|
+
description: Positional arguments only
|
|
953
|
+
- input: '{{ my_flat_hash | to_cli_args: "env_arg" }}'
|
|
954
|
+
output: 'KEY1=valuu_one KEY2=val_two KEY3=third value'
|
|
955
|
+
description: Environment variable format (uppercase keys)
|
|
956
|
+
- input: '{{ my_flat_hash | to_cli_args: "keyval" }}'
|
|
957
|
+
output: 'key1=valuu_one key2=val_two key3=third value'
|
|
958
|
+
description: Key=value format
|
|
959
|
+
|
|
960
|
+
- key: to_yaml
|
|
961
|
+
name: Data objects to YAML
|
|
962
|
+
source: asciisourcerer
|
|
963
|
+
kind: object-conversion
|
|
964
|
+
description: Turn any parameter or data object into YAML format.
|
|
965
|
+
examples:
|
|
966
|
+
- input: '{{ my_flat_hash | to_yaml }}'
|
|
967
|
+
output: |
|
|
968
|
+
---
|
|
969
|
+
key1: valuu_one
|
|
970
|
+
key2: val_two
|
|
971
|
+
key3: third value
|
|
972
|
+
- input: '{{ my_flat_hash | to_yaml: "flow" }}'
|
|
973
|
+
output: '{key1: "valuu_one", key2: "val_two", key3: "third value"}'
|
|
974
|
+
- input: '{{ page.tags | to_yaml }}'
|
|
975
|
+
output: |
|
|
976
|
+
---
|
|
977
|
+
- Seattle
|
|
978
|
+
- Tacoma
|
|
979
|
+
- Spokane
|
|
980
|
+
- input: '{{ page.tags | to_yaml: "flow" }}'
|
|
981
|
+
output: '["Seattle", "Tacoma", "Spokane"]'
|
|
982
|
+
- input: '{{ page.tags | to_yaml: "flow", "quotes" }}'
|
|
983
|
+
output: '["Seattle", "Tacoma", "Spokane"]'
|
|
984
|
+
|
|
985
|
+
- key: to_json
|
|
986
|
+
name: Data objects to JSON
|
|
987
|
+
source: asciisourcerer
|
|
988
|
+
kind: object-conversion
|
|
989
|
+
description: Turn any parameter or data object into JSON format.
|
|
990
|
+
examples:
|
|
991
|
+
- input: '{{ my_flat_hash | to_json }}'
|
|
992
|
+
output: |
|
|
993
|
+
{"key1":"valuu_one","key2":"val_two","key3":"third value"}
|
|
994
|
+
- input: '{{ page.tags | to_json }}'
|
|
995
|
+
output: |
|
|
996
|
+
["Seattle","Tacoma","Spokane"]
|
|
997
|
+
- input: '{{ odd_keys_hash | to_json }}'
|
|
998
|
+
output: |
|
|
999
|
+
{"key 1":"valuu_one","$key2":"val_two","key:3":"third value"}
|
|
1000
|
+
|
|
1001
|
+
- key: regexreplace
|
|
1002
|
+
deprecated: true
|
|
1003
|
+
|
|
1004
|
+
- key: replace_regex
|
|
1005
|
+
name: Regular Expression Replace
|
|
1006
|
+
source: asciisourcerer
|
|
1007
|
+
alias: regexreplace
|
|
1008
|
+
description: Use regular expressions to match and replace text patterns.
|
|
1009
|
+
kind: string-management
|
|
1010
|
+
examples:
|
|
1011
|
+
- input: '{{ "hello world" | replace_regex: "world", "there" }}'
|
|
1012
|
+
output: "hello there"
|
|
1013
|
+
- input: '{{ "one,two,three" | replace_regex: ",", "-" }}'
|
|
1014
|
+
output: "one-two-three"
|
|
1015
|
+
|
|
1016
|
+
- key: match
|
|
1017
|
+
name: Pattern Match
|
|
1018
|
+
source: asciisourcerer
|
|
1019
|
+
description: Returns of string or number matches pattern.
|
|
1020
|
+
kind: string-analysis
|
|
1021
|
+
examples:
|
|
1022
|
+
- input: |
|
|
1023
|
+
{% assign matched = "testword" | match: "^.*word$" %}
|
|
1024
|
+
{% if matched %}It matched!{% endif %}
|
|
1025
|
+
output: "It matched!"
|
|
1026
|
+
|
|
1027
|
+
# - key: transliterate
|
|
1028
|
+
# name: Transliterate to ASCII
|
|
1029
|
+
# source: sterile
|
|
1030
|
+
# description: Convert Unicode [and accented ASCII] characters to their plain-text ASCII equivalents.
|
|
1031
|
+
# group: string-recode
|
|
1032
|
+
# examples:
|
|
1033
|
+
# - input: '{{ "šţɽĩɳģ" | transliterate }}'
|
|
1034
|
+
# output: string
|
|
1035
|
+
|
|
1036
|
+
# - key: smart_format
|
|
1037
|
+
# name: Smart Format
|
|
1038
|
+
# source: sterile
|
|
1039
|
+
# description: Convert UTF-8 or HTML-tagged text to “curly” quotes, emdashes, copyright, trademark, etc.
|
|
1040
|
+
# group: string-conversion
|
|
1041
|
+
# examples:
|
|
1042
|
+
# - input: |
|
|
1043
|
+
# {% capture statement %}“He said, ‘Away, Drake!’”{% endcapture %}
|
|
1044
|
+
# {{ statement | smart_format }}
|
|
1045
|
+
# output: “He said, ‘Away, Drake!’”
|
|
1046
|
+
# - input: |
|
|
1047
|
+
# {% capture statement %}"He said, <b>'Away, Drake!'</b>"{% endcapture %}
|
|
1048
|
+
# {{ statement | smart_format }}
|
|
1049
|
+
# output: “He said, ‘Away, Drake!’”
|
|
1050
|
+
|
|
1051
|
+
# - key: encode_entities
|
|
1052
|
+
# name: Encode Entities
|
|
1053
|
+
# source: sterile
|
|
1054
|
+
# description: Turn Unicode characters into their HTML equivilents.
|
|
1055
|
+
# group: string-recode
|
|
1056
|
+
# examples:
|
|
1057
|
+
# - input: '{{ "“Economy Hits Bottom,” ran the headline" | encode_entities }}'
|
|
1058
|
+
# output: '“Economy Hits Bottom,” ran the headline'
|
|
1059
|
+
|
|
1060
|
+
# - key: decode_entities
|
|
1061
|
+
# name: Decode Entities
|
|
1062
|
+
# source: sterile
|
|
1063
|
+
# description: Turn HTML entities into Unicode characters.
|
|
1064
|
+
# group: string-recode
|
|
1065
|
+
# examples:
|
|
1066
|
+
# - input: '{{ "“Economy Hits Bottom,” ran the headline" | decode_entities }}'
|
|
1067
|
+
# output: '“Economy Hits Bottom,” ran the headline'
|
|
1068
|
+
|
|
1069
|
+
# - key: titlecase
|
|
1070
|
+
# name: Titlecase
|
|
1071
|
+
# source: sterile
|
|
1072
|
+
# description: Format text appropriately for titles.
|
|
1073
|
+
# group: string-conversion
|
|
1074
|
+
# examples:
|
|
1075
|
+
# - output: "Q&A With Steve Jobs: 'That's What Happens in Technology'"
|
|
1076
|
+
# input: |
|
|
1077
|
+
# {{ "Q&A with Steve Jobs: 'That's what happens in technology'" | titlecase }}
|
|
1078
|
+
# test: false
|
|
1079
|
+
|
|
1080
|
+
# - key: strip_tags
|
|
1081
|
+
# name: Strip Tags
|
|
1082
|
+
# source: sterile
|
|
1083
|
+
# description: Remove HTML/XML tags from text. Also strips out comments, PHP and ERB style tags.
|
|
1084
|
+
# group: string-conversion
|
|
1085
|
+
# examples:
|
|
1086
|
+
# - output: 'Visit our website!'
|
|
1087
|
+
# input: '{{ "Visit our <a href=\"http://example.com\">website!</a>" | strip_tags }}'
|
|
1088
|
+
# test: false
|
|
1089
|
+
|
|
1090
|
+
# - key: sterilize
|
|
1091
|
+
# name: Sterilize
|
|
1092
|
+
# source: sterile
|
|
1093
|
+
# description: Transliterate to ASCII and strip out any HTML/XML tags.
|
|
1094
|
+
# group: string-recode
|
|
1095
|
+
# examples:
|
|
1096
|
+
# - input: '{{ "<b>nåsty</b>" | sterilize }}'
|
|
1097
|
+
# output: nasty
|
|
1098
|
+
|
|
1099
|
+
- key: holds_liquid
|
|
1100
|
+
name: Holds Liquid
|
|
1101
|
+
source: asciisourcerer
|
|
1102
|
+
description: Returns true if a snippet of text contains Liquid markup tags.
|
|
1103
|
+
kind: object-analysis
|
|
1104
|
+
examples:
|
|
1105
|
+
- input: |
|
|
1106
|
+
{{ liquidy_text | holds_liquid }}
|
|
1107
|
+
output: 'true'
|
|
1108
|
+
- input: |
|
|
1109
|
+
{{ "This is just text." | holds_liquid }}
|
|
1110
|
+
output: 'false'
|
|
1111
|
+
|
|
1112
|
+
- key: store_list_concat
|
|
1113
|
+
name: Metastore list concat
|
|
1114
|
+
source: asciisourcerer
|
|
1115
|
+
description: |
|
|
1116
|
+
Concatenates each Array-formatted value of the same-named property across all nodes in an Array of Hashes (Metastore).
|
|
1117
|
+
Accepts an Array of Hashes and the keyname of a property to collect from.
|
|
1118
|
+
kind: array-management
|
|
1119
|
+
examples:
|
|
1120
|
+
- input: |
|
|
1121
|
+
{{ data.metastore | store_list_concat: "children" | jsonify }}
|
|
1122
|
+
output: '["child1","child2","child3","child4","child5","child6"]'
|
|
1123
|
+
|
|
1124
|
+
- key: store_list_dupes
|
|
1125
|
+
name: Metastore list duplicates
|
|
1126
|
+
source: asciisourcerer
|
|
1127
|
+
description: |
|
|
1128
|
+
Returns a list of duplicate items among multiple Arrays across multiple same-named properties in an Array of Hashes (Metastore).
|
|
1129
|
+
Accepts an Array of Hashes and the keyname of a Scalar property to check; returns the names of duplicate properties.
|
|
1130
|
+
kind: array-management
|
|
1131
|
+
examples:
|
|
1132
|
+
- input: |
|
|
1133
|
+
{{ data.metastore | store_list_dupes: "children" | jsonify }}
|
|
1134
|
+
output: '["child1"]'
|
|
1135
|
+
|
|
1136
|
+
- key: relative_url
|
|
1137
|
+
name: Relative URL
|
|
1138
|
+
source: jekyll
|
|
1139
|
+
description: |
|
|
1140
|
+
Prepend `baseurl` config value to the input to convert a URL path into a relative URL.
|
|
1141
|
+
This is recommended for a site that is hosted on a subpath of a domain.
|
|
1142
|
+
|
|
1143
|
+
NOTE: Requires registration of a `site.baseurl` object outside `jekyll build` contexts.
|
|
1144
|
+
kind: string-conversion
|
|
1145
|
+
examples:
|
|
1146
|
+
- input: '{{ "test-path" | relative_url }}'
|
|
1147
|
+
output: "/docs/test-path"
|
|
1148
|
+
|
|
1149
|
+
- key: absolute_url
|
|
1150
|
+
name: Absolute URL
|
|
1151
|
+
source: jekyll
|
|
1152
|
+
description: |
|
|
1153
|
+
Prepend `url` and `baseurl` values to the input to convert a URL path to an absolute URL.
|
|
1154
|
+
|
|
1155
|
+
NOTE: Requires registration of `site.baseurl` and `site.url` objects outside `jekyll build` contexts.
|
|
1156
|
+
kind: string-conversion
|
|
1157
|
+
examples:
|
|
1158
|
+
- input: '{{ "test-path" | absolute_url }}'
|
|
1159
|
+
output: "https://example.com/docs/test-path"
|
|
1160
|
+
|
|
1161
|
+
- key: markdownify
|
|
1162
|
+
name: Markdownify
|
|
1163
|
+
source: jekyll
|
|
1164
|
+
description: Converts a Markdown string to HTML.
|
|
1165
|
+
kind: string-conversion
|
|
1166
|
+
examples:
|
|
1167
|
+
- input: '{{ "Test with **bold** and a [link](https://example.com)." | markdownify }}'
|
|
1168
|
+
output: '<p>Test with <strong>bold</strong> and a <a href="https://example.com">link</a>.</p>'
|
|
1169
|
+
|
|
1170
|
+
- key: smartify
|
|
1171
|
+
name: Smartify
|
|
1172
|
+
source: jekyll
|
|
1173
|
+
description: 'Convert "quotes" into “smart quotes.”'
|
|
1174
|
+
kind: string-conversion
|
|
1175
|
+
examples:
|
|
1176
|
+
- input: |
|
|
1177
|
+
{{ 'He said, "Hello!"' | smartify }}
|
|
1178
|
+
output: "He said, “Hello!”"
|
|
1179
|
+
|
|
1180
|
+
|
|
1181
|
+
- key: sassify
|
|
1182
|
+
name: Sassify
|
|
1183
|
+
source: jekyll
|
|
1184
|
+
description: Convert an indented-syntax Sass string into CSS.
|
|
1185
|
+
kind: string-conversion
|
|
1186
|
+
examples:
|
|
1187
|
+
- input: |
|
|
1188
|
+
{{ sass_text | sassify }}
|
|
1189
|
+
output: |
|
|
1190
|
+
body {
|
|
1191
|
+
color: red;
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
- key: scssify
|
|
1195
|
+
name: Scssify
|
|
1196
|
+
source: jekyll
|
|
1197
|
+
description: Convert a SCSS-formatted (brace/semicolon syntax) string into CSS.
|
|
1198
|
+
kind: string-conversion
|
|
1199
|
+
examples:
|
|
1200
|
+
- input: |
|
|
1201
|
+
{{ scss_text | scssify }}
|
|
1202
|
+
output: |
|
|
1203
|
+
body {
|
|
1204
|
+
color: red;
|
|
1205
|
+
}
|
|
1206
|
+
|
|
1207
|
+
- key: asciidocify
|
|
1208
|
+
name: AsciiDocify
|
|
1209
|
+
source: jekyll-asciidoc
|
|
1210
|
+
description: Convert an AsciiDoc string to HTML, with or without paragraphing.
|
|
1211
|
+
kind: string-conversion
|
|
1212
|
+
examples:
|
|
1213
|
+
- input: |
|
|
1214
|
+
{{ "Test with *bold* and a http://example.com[link]." | asciidocify }}
|
|
1215
|
+
output: |
|
|
1216
|
+
<div class="paragraph">
|
|
1217
|
+
<p>Test with <strong>bold</strong> and a <a href="http://example.com">link</a>.</p>
|
|
1218
|
+
</div>
|
|
1219
|
+
- input: |
|
|
1220
|
+
{{ "Test with *bold* and a http://example.com[link]." | asciidocify: "inline" }}
|
|
1221
|
+
output: |
|
|
1222
|
+
Test with <strong>bold</strong> and a <a href="http://example.com">link</a>.
|
|
1223
|
+
|
|
1224
|
+
sources:
|
|
1225
|
+
jekyll:
|
|
1226
|
+
name: Jekyll
|
|
1227
|
+
url: https://jekyllrb.com/docs/liquid/filters/
|
|
1228
|
+
shopify:
|
|
1229
|
+
name: Shopify
|
|
1230
|
+
url: https://shopify.github.io/liquid/filters/
|
|
1231
|
+
asciisourcerer:
|
|
1232
|
+
name: AsciiSourcerer
|
|
1233
|
+
url: https://github.com/DocOps/asciisourcerer
|
|
1234
|
+
jekyll-asciidoc:
|
|
1235
|
+
name: jekyll-asciidoc
|
|
1236
|
+
url: https://github.com/asciidoctor/jekyll-asciidoc
|
|
1237
|
+
|
|
1238
|
+
kinds:
|
|
1239
|
+
- key: date-format
|
|
1240
|
+
name: Date Formatting
|
|
1241
|
+
- key: array-select
|
|
1242
|
+
name: Array Selection
|
|
1243
|
+
- key: array-organizing
|
|
1244
|
+
name: Array Organizing
|
|
1245
|
+
- key: string-escape
|
|
1246
|
+
name: String Escaping
|
|
1247
|
+
- key: string-analysis
|
|
1248
|
+
name: String Analysis
|
|
1249
|
+
- key: object-conversion
|
|
1250
|
+
name: Object Conversion
|
|
1251
|
+
- key: string-conversion
|
|
1252
|
+
name: String Conversion
|
|
1253
|
+
- key: string-management
|
|
1254
|
+
name: String Management
|
|
1255
|
+
- key: array-management
|
|
1256
|
+
name: Array Management
|
|
1257
|
+
- key: object-analysis
|
|
1258
|
+
name: Object Analysis
|
|
1259
|
+
- key: math
|
|
1260
|
+
name: Math Operations
|
|
1261
|
+
- key: string-recode
|
|
1262
|
+
name: String Recode
|
|
1263
|
+
- key: variable
|
|
1264
|
+
name: Variable Defaults
|
|
1265
|
+
|
|
1266
|
+
example_data:
|
|
1267
|
+
tags_array: ['foo', 'bar', 'baz']
|
|
1268
|
+
my_flat_hash:
|
|
1269
|
+
key1: valuu_one
|
|
1270
|
+
key2: val_two
|
|
1271
|
+
key3: 'third value'
|
|
1272
|
+
cli_flags_hash: # distinct first letters, for the to_cli_args short_flag example
|
|
1273
|
+
kind: valuu_one
|
|
1274
|
+
verbose: val_two
|
|
1275
|
+
output: 'third value'
|
|
1276
|
+
odd_keys_hash: # a map of YAML node keys with odd chars, spaces, etc
|
|
1277
|
+
"key 1": valuu_one
|
|
1278
|
+
"$key2": val_two
|
|
1279
|
+
"key:3": 'third value'
|
|
1280
|
+
comment_text: 'A string that is obviously longer than 25 characters'
|
|
1281
|
+
mixed_array: ['a', null, 'b', null, 'c']
|
|
1282
|
+
liquidy_text: "{% assign var = 'anything' %}"
|
|
1283
|
+
scss_text: '$color: red; body { color: $color; }'
|
|
1284
|
+
sass_text: |
|
|
1285
|
+
$color: red
|
|
1286
|
+
body
|
|
1287
|
+
color: $color
|
|
1288
|
+
data:
|
|
1289
|
+
metastore:
|
|
1290
|
+
- {name: "node1", children: ["child1", "child2"], type: "typeA"}
|
|
1291
|
+
- {name: "node2", children: ["child3", "child4"], type: "typeB"}
|
|
1292
|
+
- {name: "node3", children: ["child1", "child5", "child6"], type: "typeA"}
|
|
1293
|
+
time: 2008-11-07T13:07:54-08:00
|
|
1294
|
+
users:
|
|
1295
|
+
- {user: "alice", level: 1}
|
|
1296
|
+
- {user: "andie", level: 2}
|
|
1297
|
+
- {user: "boris", level: 1}
|
|
1298
|
+
members:
|
|
1299
|
+
- {user: "andie", grad_year: 2014, projects: ["fooman", "barbaz"]}
|
|
1300
|
+
- {user: "lonnie", grad_year: 2014, projects: ["fooman"]}
|
|
1301
|
+
- {user: "cindy", grad_year: 2012, projects: ["fooman", "foobar"]}
|
|
1302
|
+
page:
|
|
1303
|
+
tags: ["Seattle", "Tacoma", "Spokane"]
|
|
1304
|
+
content: "One Two Three"
|
|
1305
|
+
site:
|
|
1306
|
+
url: "https://example.com"
|
|
1307
|
+
baseurl: "/docs"
|
|
1308
|
+
pages:
|
|
1309
|
+
- {title: "Home", path: "/"}
|
|
1310
|
+
- {title: "About", path: "/about"}
|
|
1311
|
+
- {title: "Contact", path: "/contact"}
|
|
1312
|
+
posts:
|
|
1313
|
+
- {title: "First Post", author: "alice", date: 2024-01-01}
|
|
1314
|
+
- {title: "Second Post", author: "bob", date: 2024-01-15}
|