asciisourcerer 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 +4 -4
- data/BILL_OF_MATERIALS.adoc +17 -0
- data/README.adoc +87 -7
- 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 +10 -3
- data/lib/sourcerer/builder.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 +181 -28
- data/lib/sourcerer/rendering.rb +9 -3
- 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 +26 -4
- data/specs/docs/frontmatter-reader_prd.adoc +0 -47
|
@@ -0,0 +1,3227 @@
|
|
|
1
|
+
|
|
2
|
+
:example-capition!:
|
|
3
|
+
|
|
4
|
+
[[date-format]]
|
|
5
|
+
== Date format Filters
|
|
6
|
+
|
|
7
|
+
// tag::date-format[]
|
|
8
|
+
[[filter__date_to_xml_schema,Date to XML Schema]]
|
|
9
|
+
Date to XML Schema (`date_to_xml_schema`)::
|
|
10
|
+
+
|
|
11
|
+
--
|
|
12
|
+
Convert a Date into XML Schema (ISO 8601) format.
|
|
13
|
+
|
|
14
|
+
[horizontal]
|
|
15
|
+
Source::: Jekyll
|
|
16
|
+
|
|
17
|
+
[vertical]
|
|
18
|
+
Examples:::
|
|
19
|
+
+
|
|
20
|
+
====
|
|
21
|
+
.Input
|
|
22
|
+
[source,liquid]
|
|
23
|
+
----
|
|
24
|
+
{{ "2008-11-07 1:07:54pm" | date_to_xmlschema }}
|
|
25
|
+
----
|
|
26
|
+
|
|
27
|
+
.Output
|
|
28
|
+
[source,liquid]
|
|
29
|
+
----
|
|
30
|
+
2008-11-07T13:07:54-08:00
|
|
31
|
+
----
|
|
32
|
+
====
|
|
33
|
+
--
|
|
34
|
+
[[filter__date_to_rfc822,Date to RFC-822 Format]]
|
|
35
|
+
Date to RFC-822 Format (`date_to_rfc822`)::
|
|
36
|
+
+
|
|
37
|
+
--
|
|
38
|
+
Convert a Date into the RFC-822 format used for RSS feeds.
|
|
39
|
+
|
|
40
|
+
[horizontal]
|
|
41
|
+
Source::: Jekyll
|
|
42
|
+
|
|
43
|
+
[vertical]
|
|
44
|
+
Examples:::
|
|
45
|
+
+
|
|
46
|
+
====
|
|
47
|
+
.Input
|
|
48
|
+
[source,liquid]
|
|
49
|
+
----
|
|
50
|
+
{{ data.time | date_to_rfc822 }}
|
|
51
|
+
----
|
|
52
|
+
|
|
53
|
+
.Output
|
|
54
|
+
[source,liquid]
|
|
55
|
+
----
|
|
56
|
+
Fri, 07 Nov 2008 13:07:54 -0800
|
|
57
|
+
----
|
|
58
|
+
====
|
|
59
|
+
--
|
|
60
|
+
[[filter__date_to_string,Date to String]]
|
|
61
|
+
Date to String (`date_to_string`)::
|
|
62
|
+
+
|
|
63
|
+
--
|
|
64
|
+
Convert a date to short format.
|
|
65
|
+
|
|
66
|
+
[horizontal]
|
|
67
|
+
Source::: Jekyll
|
|
68
|
+
|
|
69
|
+
[vertical]
|
|
70
|
+
Examples:::
|
|
71
|
+
+
|
|
72
|
+
====
|
|
73
|
+
.Input
|
|
74
|
+
[source,liquid]
|
|
75
|
+
----
|
|
76
|
+
{{ data.time | date_to_string }}
|
|
77
|
+
----
|
|
78
|
+
|
|
79
|
+
.Output
|
|
80
|
+
[source,liquid]
|
|
81
|
+
----
|
|
82
|
+
07 Nov 2008
|
|
83
|
+
----
|
|
84
|
+
====
|
|
85
|
+
+
|
|
86
|
+
====
|
|
87
|
+
.Input
|
|
88
|
+
[source,liquid]
|
|
89
|
+
----
|
|
90
|
+
{{ data.time | date_to_string: "ordinal", "US" }}
|
|
91
|
+
----
|
|
92
|
+
|
|
93
|
+
.Output
|
|
94
|
+
[source,liquid]
|
|
95
|
+
----
|
|
96
|
+
Nov 7th, 2008
|
|
97
|
+
----
|
|
98
|
+
====
|
|
99
|
+
--
|
|
100
|
+
[[filter__date_to_long_string,Date to Long String]]
|
|
101
|
+
Date to Long String (`date_to_long_string`)::
|
|
102
|
+
+
|
|
103
|
+
--
|
|
104
|
+
Format a date to long format.
|
|
105
|
+
|
|
106
|
+
[horizontal]
|
|
107
|
+
Source::: Jekyll
|
|
108
|
+
|
|
109
|
+
[vertical]
|
|
110
|
+
Examples:::
|
|
111
|
+
+
|
|
112
|
+
====
|
|
113
|
+
.Input
|
|
114
|
+
[source,liquid]
|
|
115
|
+
----
|
|
116
|
+
{{ data.time | date_to_long_string }}
|
|
117
|
+
----
|
|
118
|
+
|
|
119
|
+
.Output
|
|
120
|
+
[source,liquid]
|
|
121
|
+
----
|
|
122
|
+
07 November 2008
|
|
123
|
+
----
|
|
124
|
+
====
|
|
125
|
+
+
|
|
126
|
+
====
|
|
127
|
+
.Input
|
|
128
|
+
[source,liquid]
|
|
129
|
+
----
|
|
130
|
+
{{ data.time | date_to_long_string: "ordinal" }}
|
|
131
|
+
----
|
|
132
|
+
|
|
133
|
+
.Output
|
|
134
|
+
[source,liquid]
|
|
135
|
+
----
|
|
136
|
+
7th November 2008
|
|
137
|
+
----
|
|
138
|
+
====
|
|
139
|
+
--
|
|
140
|
+
[[filter__date,Date Format]]
|
|
141
|
+
Date Format (`date`)::
|
|
142
|
+
+
|
|
143
|
+
--
|
|
144
|
+
Converts a timestamp into another date format, using the same format
|
|
145
|
+
syntax as `strftime`.
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
[horizontal]
|
|
149
|
+
Source::: Shopify
|
|
150
|
+
|
|
151
|
+
[vertical]
|
|
152
|
+
Examples:::
|
|
153
|
+
+
|
|
154
|
+
====
|
|
155
|
+
.Input
|
|
156
|
+
[source,liquid]
|
|
157
|
+
----
|
|
158
|
+
{{ data.time | date: "%Y-%m-%d" }}
|
|
159
|
+
----
|
|
160
|
+
|
|
161
|
+
.Output
|
|
162
|
+
[source,liquid]
|
|
163
|
+
----
|
|
164
|
+
2008-11-07
|
|
165
|
+
----
|
|
166
|
+
====
|
|
167
|
+
--
|
|
168
|
+
// end::date-format[]
|
|
169
|
+
|
|
170
|
+
:example-capition!:
|
|
171
|
+
|
|
172
|
+
[[array-select]]
|
|
173
|
+
== Array select Filters
|
|
174
|
+
|
|
175
|
+
// tag::array-select[]
|
|
176
|
+
[[filter__where,Where]]
|
|
177
|
+
Where (`where`)::
|
|
178
|
+
+
|
|
179
|
+
--
|
|
180
|
+
Select all the objects in an array where the key has the given value.
|
|
181
|
+
|
|
182
|
+
[horizontal]
|
|
183
|
+
Source::: Jekyll
|
|
184
|
+
|
|
185
|
+
[vertical]
|
|
186
|
+
Examples:::
|
|
187
|
+
+
|
|
188
|
+
====
|
|
189
|
+
.Input
|
|
190
|
+
[source,liquid]
|
|
191
|
+
----
|
|
192
|
+
{% assign filtered = data.users | where:"level", 2 %}
|
|
193
|
+
{{ filtered | size }}
|
|
194
|
+
|
|
195
|
+
----
|
|
196
|
+
|
|
197
|
+
.Output
|
|
198
|
+
[source,liquid]
|
|
199
|
+
----
|
|
200
|
+
1
|
|
201
|
+
----
|
|
202
|
+
====
|
|
203
|
+
+
|
|
204
|
+
====
|
|
205
|
+
.Input
|
|
206
|
+
[source,liquid]
|
|
207
|
+
----
|
|
208
|
+
{% assign member = data.users | where:"user","alice" %}
|
|
209
|
+
{{ member[0] | jsonify }}
|
|
210
|
+
|
|
211
|
+
----
|
|
212
|
+
|
|
213
|
+
.Output
|
|
214
|
+
[source,liquid]
|
|
215
|
+
----
|
|
216
|
+
{"user":"alice","level":1}
|
|
217
|
+
----
|
|
218
|
+
====
|
|
219
|
+
--
|
|
220
|
+
[[filter__where_exp,Where Expression]]
|
|
221
|
+
Where Expression (`where_exp`)::
|
|
222
|
+
+
|
|
223
|
+
--
|
|
224
|
+
Select all the objects in an array where the expression is true.
|
|
225
|
+
|
|
226
|
+
[horizontal]
|
|
227
|
+
Source::: Jekyll
|
|
228
|
+
|
|
229
|
+
[vertical]
|
|
230
|
+
Examples:::
|
|
231
|
+
+
|
|
232
|
+
====
|
|
233
|
+
.Input
|
|
234
|
+
[source,liquid]
|
|
235
|
+
----
|
|
236
|
+
{{ data.members | where_exp:"item",
|
|
237
|
+
"item.grad_year == 2014" | jsonify }}
|
|
238
|
+
|
|
239
|
+
----
|
|
240
|
+
|
|
241
|
+
.Output
|
|
242
|
+
[source,liquid]
|
|
243
|
+
----
|
|
244
|
+
[{"user":"andie","grad_year":2014,"projects":["fooman","barbaz"]},{"user":"lonnie","grad_year":2014,"projects":["fooman"]}]
|
|
245
|
+
----
|
|
246
|
+
====
|
|
247
|
+
+
|
|
248
|
+
====
|
|
249
|
+
.Input
|
|
250
|
+
[source,liquid]
|
|
251
|
+
----
|
|
252
|
+
{{ data.members | where_exp:"item",
|
|
253
|
+
"item.grad_year < 2014" | jsonify }}
|
|
254
|
+
|
|
255
|
+
----
|
|
256
|
+
|
|
257
|
+
.Output
|
|
258
|
+
[source,liquid]
|
|
259
|
+
----
|
|
260
|
+
[{"user":"cindy","grad_year":2012,"projects":["fooman","foobar"]}]
|
|
261
|
+
----
|
|
262
|
+
====
|
|
263
|
+
+
|
|
264
|
+
====
|
|
265
|
+
.Input
|
|
266
|
+
[source,liquid]
|
|
267
|
+
----
|
|
268
|
+
{{ data.members | where_exp:"item",
|
|
269
|
+
"item.projects contains 'barbaz'" | jsonify }}
|
|
270
|
+
|
|
271
|
+
----
|
|
272
|
+
|
|
273
|
+
.Output
|
|
274
|
+
[source,liquid]
|
|
275
|
+
----
|
|
276
|
+
[{"user":"andie","grad_year":2014,"projects":["fooman","barbaz"]}]
|
|
277
|
+
----
|
|
278
|
+
====
|
|
279
|
+
--
|
|
280
|
+
[[filter__sample,Sample]]
|
|
281
|
+
Sample (`sample`)::
|
|
282
|
+
+
|
|
283
|
+
--
|
|
284
|
+
Pick a random value from an array. Optionally, pick multiple values.
|
|
285
|
+
|
|
286
|
+
[horizontal]
|
|
287
|
+
Source::: Jekyll
|
|
288
|
+
|
|
289
|
+
[vertical]
|
|
290
|
+
Examples:::
|
|
291
|
+
+
|
|
292
|
+
====
|
|
293
|
+
.Input
|
|
294
|
+
[source,liquid]
|
|
295
|
+
----
|
|
296
|
+
{{ site.pages | sample }}
|
|
297
|
+
----
|
|
298
|
+
====
|
|
299
|
+
+
|
|
300
|
+
====
|
|
301
|
+
.Input
|
|
302
|
+
[source,liquid]
|
|
303
|
+
----
|
|
304
|
+
{{ site.pages | sample: 2 }}
|
|
305
|
+
----
|
|
306
|
+
====
|
|
307
|
+
--
|
|
308
|
+
[[filter__first,First]]
|
|
309
|
+
First (`first`)::
|
|
310
|
+
+
|
|
311
|
+
--
|
|
312
|
+
Returns the first item of an array.
|
|
313
|
+
|
|
314
|
+
[horizontal]
|
|
315
|
+
Source::: Shopify
|
|
316
|
+
|
|
317
|
+
[vertical]
|
|
318
|
+
Examples:::
|
|
319
|
+
+
|
|
320
|
+
====
|
|
321
|
+
.Input
|
|
322
|
+
[source,liquid]
|
|
323
|
+
----
|
|
324
|
+
{{ "Ground control to Major Tom." | split: " " | first }}
|
|
325
|
+
----
|
|
326
|
+
|
|
327
|
+
.Output
|
|
328
|
+
[source,liquid]
|
|
329
|
+
----
|
|
330
|
+
Ground
|
|
331
|
+
----
|
|
332
|
+
====
|
|
333
|
+
--
|
|
334
|
+
[[filter__last,Last]]
|
|
335
|
+
Last (`last`)::
|
|
336
|
+
+
|
|
337
|
+
--
|
|
338
|
+
Returns the last item of an array.
|
|
339
|
+
|
|
340
|
+
[horizontal]
|
|
341
|
+
Source::: Shopify
|
|
342
|
+
|
|
343
|
+
[vertical]
|
|
344
|
+
Examples:::
|
|
345
|
+
+
|
|
346
|
+
====
|
|
347
|
+
.Input
|
|
348
|
+
[source,liquid]
|
|
349
|
+
----
|
|
350
|
+
{{ "Ground control to Major Tom." | split: " " | last }}
|
|
351
|
+
----
|
|
352
|
+
|
|
353
|
+
.Output
|
|
354
|
+
[source,liquid]
|
|
355
|
+
----
|
|
356
|
+
Tom.
|
|
357
|
+
----
|
|
358
|
+
====
|
|
359
|
+
--
|
|
360
|
+
// end::array-select[]
|
|
361
|
+
|
|
362
|
+
:example-capition!:
|
|
363
|
+
|
|
364
|
+
[[array-organizing]]
|
|
365
|
+
== Array organizing Filters
|
|
366
|
+
|
|
367
|
+
// tag::array-organizing[]
|
|
368
|
+
[[filter__group_by,Group By]]
|
|
369
|
+
Group By (`group_by`)::
|
|
370
|
+
+
|
|
371
|
+
--
|
|
372
|
+
Group an array's items by a given property.
|
|
373
|
+
|
|
374
|
+
[horizontal]
|
|
375
|
+
Source::: Jekyll
|
|
376
|
+
|
|
377
|
+
[vertical]
|
|
378
|
+
Examples:::
|
|
379
|
+
+
|
|
380
|
+
====
|
|
381
|
+
.Input
|
|
382
|
+
[source,liquid]
|
|
383
|
+
----
|
|
384
|
+
{% assign grouped = data.members | group_by:"grad_year" | first %}
|
|
385
|
+
{{ grouped.name }}
|
|
386
|
+
|
|
387
|
+
----
|
|
388
|
+
|
|
389
|
+
.Output
|
|
390
|
+
[source,liquid]
|
|
391
|
+
----
|
|
392
|
+
2014
|
|
393
|
+
----
|
|
394
|
+
====
|
|
395
|
+
--
|
|
396
|
+
[[filter__group_by_exp,Group By Expression]]
|
|
397
|
+
Group By Expression (`group_by_exp`)::
|
|
398
|
+
+
|
|
399
|
+
--
|
|
400
|
+
Group an array's items using a Liquid expression.
|
|
401
|
+
|
|
402
|
+
[horizontal]
|
|
403
|
+
Source::: Jekyll
|
|
404
|
+
|
|
405
|
+
[vertical]
|
|
406
|
+
Examples:::
|
|
407
|
+
+
|
|
408
|
+
====
|
|
409
|
+
.Input
|
|
410
|
+
[source,liquid]
|
|
411
|
+
----
|
|
412
|
+
{{ data.members | group_by_exp: "item", "item.grad_year" | map: "name" | join: "," }}
|
|
413
|
+
----
|
|
414
|
+
|
|
415
|
+
.Output
|
|
416
|
+
[source,liquid]
|
|
417
|
+
----
|
|
418
|
+
2014,2012
|
|
419
|
+
----
|
|
420
|
+
====
|
|
421
|
+
--
|
|
422
|
+
[[filter__sort,Sort]]
|
|
423
|
+
Sort (`sort`)::
|
|
424
|
+
+
|
|
425
|
+
--
|
|
426
|
+
Sort an array. Optional arguments for hashes
|
|
427
|
+
1. property name
|
|
428
|
+
2. nils order (_first_ or _last_).
|
|
429
|
+
|
|
430
|
+
|
|
431
|
+
[horizontal]
|
|
432
|
+
Source::: Jekyll
|
|
433
|
+
|
|
434
|
+
[vertical]
|
|
435
|
+
Examples:::
|
|
436
|
+
+
|
|
437
|
+
====
|
|
438
|
+
.Input
|
|
439
|
+
[source,liquid]
|
|
440
|
+
----
|
|
441
|
+
{{ page.tags | sort | inspect }}
|
|
442
|
+
----
|
|
443
|
+
|
|
444
|
+
.Output
|
|
445
|
+
[source,liquid]
|
|
446
|
+
----
|
|
447
|
+
["Seattle", "Spokane", "Tacoma"]
|
|
448
|
+
----
|
|
449
|
+
====
|
|
450
|
+
+
|
|
451
|
+
====
|
|
452
|
+
.Input
|
|
453
|
+
[source,liquid]
|
|
454
|
+
----
|
|
455
|
+
{{ site.posts | sort: "author" }}
|
|
456
|
+
----
|
|
457
|
+
====
|
|
458
|
+
+
|
|
459
|
+
====
|
|
460
|
+
.Input
|
|
461
|
+
[source,liquid]
|
|
462
|
+
----
|
|
463
|
+
{{ site.pages | sort: "title", "last" }}
|
|
464
|
+
----
|
|
465
|
+
====
|
|
466
|
+
--
|
|
467
|
+
[[filter__reverse,Reverse]]
|
|
468
|
+
Reverse (`reverse`)::
|
|
469
|
+
+
|
|
470
|
+
--
|
|
471
|
+
Reverses the order of the items in an array. Cannot reverse a string
|
|
472
|
+
directly; split it into an array first.
|
|
473
|
+
|
|
474
|
+
|
|
475
|
+
[horizontal]
|
|
476
|
+
Source::: Shopify
|
|
477
|
+
|
|
478
|
+
[vertical]
|
|
479
|
+
Examples:::
|
|
480
|
+
+
|
|
481
|
+
====
|
|
482
|
+
.Input
|
|
483
|
+
[source,liquid]
|
|
484
|
+
----
|
|
485
|
+
{% assign arr = "apples, oranges, peaches, plums" | split: ", " %}
|
|
486
|
+
{{ arr | reverse | join: ", " }}
|
|
487
|
+
|
|
488
|
+
----
|
|
489
|
+
|
|
490
|
+
.Output
|
|
491
|
+
[source,liquid]
|
|
492
|
+
----
|
|
493
|
+
plums, peaches, oranges, apples
|
|
494
|
+
----
|
|
495
|
+
====
|
|
496
|
+
--
|
|
497
|
+
// end::array-organizing[]
|
|
498
|
+
|
|
499
|
+
:example-capition!:
|
|
500
|
+
|
|
501
|
+
[[string-escape]]
|
|
502
|
+
== String escape Filters
|
|
503
|
+
|
|
504
|
+
// tag::string-escape[]
|
|
505
|
+
[[filter__xml_escape,XML Escape]]
|
|
506
|
+
XML Escape (`xml_escape`)::
|
|
507
|
+
+
|
|
508
|
+
--
|
|
509
|
+
Escape some text for use in XML.
|
|
510
|
+
|
|
511
|
+
[horizontal]
|
|
512
|
+
Source::: Jekyll
|
|
513
|
+
|
|
514
|
+
[vertical]
|
|
515
|
+
Examples:::
|
|
516
|
+
+
|
|
517
|
+
====
|
|
518
|
+
.Input
|
|
519
|
+
[source,liquid]
|
|
520
|
+
----
|
|
521
|
+
{{ "<strong>some text</strong>" | xml_escape }}
|
|
522
|
+
----
|
|
523
|
+
|
|
524
|
+
.Output
|
|
525
|
+
[source,liquid]
|
|
526
|
+
----
|
|
527
|
+
<strong>some text</strong>
|
|
528
|
+
----
|
|
529
|
+
====
|
|
530
|
+
--
|
|
531
|
+
[[filter__cgi_escape,CGI Escape]]
|
|
532
|
+
CGI Escape (`cgi_escape`)::
|
|
533
|
+
+
|
|
534
|
+
--
|
|
535
|
+
CGI escape a string for use in a URL.
|
|
536
|
+
Replaces any special characters with appropriate `%XX` replacements.
|
|
537
|
+
CGI escape normally replaces a space with a plus `+` sign.
|
|
538
|
+
|
|
539
|
+
|
|
540
|
+
[horizontal]
|
|
541
|
+
Source::: Jekyll
|
|
542
|
+
|
|
543
|
+
[vertical]
|
|
544
|
+
Examples:::
|
|
545
|
+
+
|
|
546
|
+
====
|
|
547
|
+
.Input
|
|
548
|
+
[source,liquid]
|
|
549
|
+
----
|
|
550
|
+
{{ "foo, bar; baz?" | cgi_escape }}
|
|
551
|
+
----
|
|
552
|
+
|
|
553
|
+
.Output
|
|
554
|
+
[source,liquid]
|
|
555
|
+
----
|
|
556
|
+
foo%2C+bar%3B+baz%3F
|
|
557
|
+
----
|
|
558
|
+
====
|
|
559
|
+
--
|
|
560
|
+
[[filter__uri_escape,URI Escape]]
|
|
561
|
+
URI Escape (`uri_escape`)::
|
|
562
|
+
+
|
|
563
|
+
--
|
|
564
|
+
Percent encodes any special characters in a URI.
|
|
565
|
+
URI escape normally replaces a space with `%20`.
|
|
566
|
+
link:https://en.wikipedia.org/wiki/Percent-encoding#Types_of_URI_characters[Reserved characters]
|
|
567
|
+
will not be escaped.
|
|
568
|
+
|
|
569
|
+
|
|
570
|
+
[horizontal]
|
|
571
|
+
Source::: Jekyll
|
|
572
|
+
|
|
573
|
+
[vertical]
|
|
574
|
+
Examples:::
|
|
575
|
+
+
|
|
576
|
+
====
|
|
577
|
+
.Input
|
|
578
|
+
[source,liquid]
|
|
579
|
+
----
|
|
580
|
+
{{ "http://foo.com/?q=foo, \bar?" | uri_escape }}
|
|
581
|
+
----
|
|
582
|
+
|
|
583
|
+
.Output
|
|
584
|
+
[source,liquid]
|
|
585
|
+
----
|
|
586
|
+
http://foo.com/?q=foo,%20%5Cbar?
|
|
587
|
+
----
|
|
588
|
+
====
|
|
589
|
+
--
|
|
590
|
+
// end::string-escape[]
|
|
591
|
+
|
|
592
|
+
:example-capition!:
|
|
593
|
+
|
|
594
|
+
[[string-analysis]]
|
|
595
|
+
== String analysis Filters
|
|
596
|
+
|
|
597
|
+
// tag::string-analysis[]
|
|
598
|
+
[[filter__number_of_words,Number of Words]]
|
|
599
|
+
Number of Words (`number_of_words`)::
|
|
600
|
+
+
|
|
601
|
+
--
|
|
602
|
+
Count the number of words in a text.
|
|
603
|
+
|
|
604
|
+
[horizontal]
|
|
605
|
+
Source::: Jekyll
|
|
606
|
+
|
|
607
|
+
[vertical]
|
|
608
|
+
Examples:::
|
|
609
|
+
+
|
|
610
|
+
====
|
|
611
|
+
.Input
|
|
612
|
+
[source,liquid]
|
|
613
|
+
----
|
|
614
|
+
{{ page.content | number_of_words }}
|
|
615
|
+
----
|
|
616
|
+
|
|
617
|
+
.Output
|
|
618
|
+
[source,liquid]
|
|
619
|
+
----
|
|
620
|
+
3
|
|
621
|
+
----
|
|
622
|
+
====
|
|
623
|
+
--
|
|
624
|
+
[[filter__match,Pattern Match]]
|
|
625
|
+
Pattern Match (`match`)::
|
|
626
|
+
+
|
|
627
|
+
--
|
|
628
|
+
Returns of string or number matches pattern.
|
|
629
|
+
|
|
630
|
+
[horizontal]
|
|
631
|
+
Source::: AsciiSourcerer
|
|
632
|
+
|
|
633
|
+
[vertical]
|
|
634
|
+
Examples:::
|
|
635
|
+
+
|
|
636
|
+
====
|
|
637
|
+
.Input
|
|
638
|
+
[source,liquid]
|
|
639
|
+
----
|
|
640
|
+
{% assign matched = "testword" | match: "^.*word$" %}
|
|
641
|
+
{% if matched %}It matched!{% endif %}
|
|
642
|
+
|
|
643
|
+
----
|
|
644
|
+
|
|
645
|
+
.Output
|
|
646
|
+
[source,liquid]
|
|
647
|
+
----
|
|
648
|
+
It matched!
|
|
649
|
+
----
|
|
650
|
+
====
|
|
651
|
+
--
|
|
652
|
+
// end::string-analysis[]
|
|
653
|
+
|
|
654
|
+
:example-capition!:
|
|
655
|
+
|
|
656
|
+
[[object-conversion]]
|
|
657
|
+
== Object conversion Filters
|
|
658
|
+
|
|
659
|
+
// tag::object-conversion[]
|
|
660
|
+
[[filter__array_to_sentence_string,Array to Sentence]]
|
|
661
|
+
Array to Sentence (`array_to_sentence_string`)::
|
|
662
|
+
+
|
|
663
|
+
--
|
|
664
|
+
Convert an array into a sentence. Useful for listing tags.
|
|
665
|
+
Optional argument for connector.
|
|
666
|
+
|
|
667
|
+
|
|
668
|
+
[horizontal]
|
|
669
|
+
Source::: Jekyll
|
|
670
|
+
|
|
671
|
+
[vertical]
|
|
672
|
+
Examples:::
|
|
673
|
+
+
|
|
674
|
+
====
|
|
675
|
+
.Input
|
|
676
|
+
[source,liquid]
|
|
677
|
+
----
|
|
678
|
+
{{ tags_array | array_to_sentence_string }}
|
|
679
|
+
----
|
|
680
|
+
|
|
681
|
+
.Output
|
|
682
|
+
[source,liquid]
|
|
683
|
+
----
|
|
684
|
+
foo, bar, and baz
|
|
685
|
+
----
|
|
686
|
+
====
|
|
687
|
+
+
|
|
688
|
+
====
|
|
689
|
+
.Input
|
|
690
|
+
[source,liquid]
|
|
691
|
+
----
|
|
692
|
+
{{ tags_array | array_to_sentence_string: "or" }}
|
|
693
|
+
----
|
|
694
|
+
|
|
695
|
+
.Output
|
|
696
|
+
[source,liquid]
|
|
697
|
+
----
|
|
698
|
+
foo, bar, or baz
|
|
699
|
+
----
|
|
700
|
+
====
|
|
701
|
+
--
|
|
702
|
+
[[filter__jsonify,Data To JSON]]
|
|
703
|
+
Data To JSON (`jsonify`)::
|
|
704
|
+
+
|
|
705
|
+
--
|
|
706
|
+
Convert Hash or Array to JSON.
|
|
707
|
+
|
|
708
|
+
[horizontal]
|
|
709
|
+
Source::: Jekyll
|
|
710
|
+
|
|
711
|
+
[vertical]
|
|
712
|
+
Examples:::
|
|
713
|
+
+
|
|
714
|
+
====
|
|
715
|
+
.Input
|
|
716
|
+
[source,liquid]
|
|
717
|
+
----
|
|
718
|
+
{{ tags_array | jsonify }}
|
|
719
|
+
----
|
|
720
|
+
|
|
721
|
+
.Output
|
|
722
|
+
[source,liquid]
|
|
723
|
+
----
|
|
724
|
+
["foo","bar","baz"]
|
|
725
|
+
----
|
|
726
|
+
====
|
|
727
|
+
--
|
|
728
|
+
[[filter__to_integer,To Integer]]
|
|
729
|
+
To Integer (`to_integer`)::
|
|
730
|
+
+
|
|
731
|
+
--
|
|
732
|
+
Convert a string or boolean to integer.
|
|
733
|
+
|
|
734
|
+
[horizontal]
|
|
735
|
+
Source::: Jekyll
|
|
736
|
+
|
|
737
|
+
[vertical]
|
|
738
|
+
Examples:::
|
|
739
|
+
+
|
|
740
|
+
====
|
|
741
|
+
.Input
|
|
742
|
+
[source,liquid]
|
|
743
|
+
----
|
|
744
|
+
{{ true | to_integer }}
|
|
745
|
+
----
|
|
746
|
+
|
|
747
|
+
.Output
|
|
748
|
+
[source,liquid]
|
|
749
|
+
----
|
|
750
|
+
1
|
|
751
|
+
----
|
|
752
|
+
====
|
|
753
|
+
+
|
|
754
|
+
====
|
|
755
|
+
.Input
|
|
756
|
+
[source,liquid]
|
|
757
|
+
----
|
|
758
|
+
{% assign five = "5" | to_integer %}
|
|
759
|
+
{% if five == 5 %}Samesies!{% endif %}
|
|
760
|
+
|
|
761
|
+
----
|
|
762
|
+
|
|
763
|
+
.Output
|
|
764
|
+
[source,liquid]
|
|
765
|
+
----
|
|
766
|
+
Samesies!
|
|
767
|
+
----
|
|
768
|
+
====
|
|
769
|
+
+
|
|
770
|
+
====
|
|
771
|
+
.Input
|
|
772
|
+
[source,liquid]
|
|
773
|
+
----
|
|
774
|
+
{{ "five" | to_integer }}
|
|
775
|
+
----
|
|
776
|
+
|
|
777
|
+
.Output
|
|
778
|
+
[source,liquid]
|
|
779
|
+
----
|
|
780
|
+
0
|
|
781
|
+
----
|
|
782
|
+
====
|
|
783
|
+
--
|
|
784
|
+
[[filter__join,Join]]
|
|
785
|
+
Join (`join`)::
|
|
786
|
+
+
|
|
787
|
+
--
|
|
788
|
+
Combines the items in an array into a single string, using the argument as a separator.
|
|
789
|
+
|
|
790
|
+
[horizontal]
|
|
791
|
+
Source::: Shopify
|
|
792
|
+
|
|
793
|
+
[vertical]
|
|
794
|
+
Examples:::
|
|
795
|
+
+
|
|
796
|
+
====
|
|
797
|
+
.Input
|
|
798
|
+
[source,liquid]
|
|
799
|
+
----
|
|
800
|
+
{% assign beatles = "John, Paul, George, Ringo" | split: ", " %}
|
|
801
|
+
{{ beatles | join: " and " }}
|
|
802
|
+
|
|
803
|
+
----
|
|
804
|
+
|
|
805
|
+
.Output
|
|
806
|
+
[source,liquid]
|
|
807
|
+
----
|
|
808
|
+
John and Paul and George and Ringo
|
|
809
|
+
----
|
|
810
|
+
====
|
|
811
|
+
--
|
|
812
|
+
[[filter__map,Map]]
|
|
813
|
+
Map (`map`)::
|
|
814
|
+
+
|
|
815
|
+
--
|
|
816
|
+
Creates an array of values by extracting the values of a named property from an array of objects.
|
|
817
|
+
|
|
818
|
+
[horizontal]
|
|
819
|
+
Source::: Shopify
|
|
820
|
+
|
|
821
|
+
[vertical]
|
|
822
|
+
Examples:::
|
|
823
|
+
+
|
|
824
|
+
====
|
|
825
|
+
.Input
|
|
826
|
+
[source,liquid]
|
|
827
|
+
----
|
|
828
|
+
{{ data.members | map: "user" | join: "," }}
|
|
829
|
+
|
|
830
|
+
----
|
|
831
|
+
|
|
832
|
+
.Output
|
|
833
|
+
[source,liquid]
|
|
834
|
+
----
|
|
835
|
+
andie,lonnie,cindy
|
|
836
|
+
----
|
|
837
|
+
====
|
|
838
|
+
--
|
|
839
|
+
[[filter__slice,Slice]]
|
|
840
|
+
Slice (`slice`)::
|
|
841
|
+
+
|
|
842
|
+
--
|
|
843
|
+
Returns a substring or array slice, starting at the index given by the
|
|
844
|
+
first argument. An optional second argument gives the length. Negative
|
|
845
|
+
indices count from the end.
|
|
846
|
+
|
|
847
|
+
|
|
848
|
+
[horizontal]
|
|
849
|
+
Source::: Shopify
|
|
850
|
+
|
|
851
|
+
[vertical]
|
|
852
|
+
Examples:::
|
|
853
|
+
+
|
|
854
|
+
====
|
|
855
|
+
.Input
|
|
856
|
+
[source,liquid]
|
|
857
|
+
----
|
|
858
|
+
{{ "Liquid" | slice: 0 }}
|
|
859
|
+
----
|
|
860
|
+
|
|
861
|
+
.Output
|
|
862
|
+
[source,liquid]
|
|
863
|
+
----
|
|
864
|
+
L
|
|
865
|
+
----
|
|
866
|
+
====
|
|
867
|
+
+
|
|
868
|
+
====
|
|
869
|
+
.Input
|
|
870
|
+
[source,liquid]
|
|
871
|
+
----
|
|
872
|
+
{{ "Liquid" | slice: 2, 3 }}
|
|
873
|
+
----
|
|
874
|
+
|
|
875
|
+
.Output
|
|
876
|
+
[source,liquid]
|
|
877
|
+
----
|
|
878
|
+
qui
|
|
879
|
+
----
|
|
880
|
+
====
|
|
881
|
+
+
|
|
882
|
+
====
|
|
883
|
+
.Input
|
|
884
|
+
[source,liquid]
|
|
885
|
+
----
|
|
886
|
+
{{ "Liquid" | slice: -3, 2 }}
|
|
887
|
+
----
|
|
888
|
+
|
|
889
|
+
.Output
|
|
890
|
+
[source,liquid]
|
|
891
|
+
----
|
|
892
|
+
ui
|
|
893
|
+
----
|
|
894
|
+
====
|
|
895
|
+
--
|
|
896
|
+
[[filter__split,Split]]
|
|
897
|
+
Split (`split`)::
|
|
898
|
+
+
|
|
899
|
+
--
|
|
900
|
+
Divides a string into an array using the argument as a separator.
|
|
901
|
+
Commonly used to convert delimited text into an array.
|
|
902
|
+
|
|
903
|
+
|
|
904
|
+
[horizontal]
|
|
905
|
+
Source::: Shopify
|
|
906
|
+
|
|
907
|
+
[vertical]
|
|
908
|
+
Examples:::
|
|
909
|
+
+
|
|
910
|
+
====
|
|
911
|
+
.Input
|
|
912
|
+
[source,liquid]
|
|
913
|
+
----
|
|
914
|
+
{% assign beatles = "John, Paul, George, Ringo" | split: ", " %}
|
|
915
|
+
{{ beatles | join: "|" }}
|
|
916
|
+
|
|
917
|
+
----
|
|
918
|
+
|
|
919
|
+
.Output
|
|
920
|
+
[source,liquid]
|
|
921
|
+
----
|
|
922
|
+
John|Paul|George|Ringo
|
|
923
|
+
----
|
|
924
|
+
====
|
|
925
|
+
--
|
|
926
|
+
[[filter__to_cli_args,Convert to CLI Arguments]]
|
|
927
|
+
Convert to CLI Arguments (`to_cli_args`)::
|
|
928
|
+
+
|
|
929
|
+
--
|
|
930
|
+
Transform a Hash into a string of CLI-formatted arguments.
|
|
931
|
+
Accepts an optional template name to format the output.
|
|
932
|
+
See `parameters` section for all available templates and their output formats.
|
|
933
|
+
When no template is specified, defaults to `long_space` format.
|
|
934
|
+
Arguments are joined with a space by default; can be customized via delimiter parameter.
|
|
935
|
+
|
|
936
|
+
|
|
937
|
+
[horizontal]
|
|
938
|
+
Source::: AsciiSourcerer
|
|
939
|
+
|
|
940
|
+
[vertical]
|
|
941
|
+
Examples:::
|
|
942
|
+
+
|
|
943
|
+
.Default (long_space) format
|
|
944
|
+
====
|
|
945
|
+
.Input
|
|
946
|
+
[source,liquid]
|
|
947
|
+
----
|
|
948
|
+
{{ my_flat_hash | to_cli_args }}
|
|
949
|
+
----
|
|
950
|
+
|
|
951
|
+
.Output
|
|
952
|
+
[source,liquid]
|
|
953
|
+
----
|
|
954
|
+
--key1 valuu_one --key2 val_two --key3 third value
|
|
955
|
+
----
|
|
956
|
+
====
|
|
957
|
+
+
|
|
958
|
+
.Long equals format
|
|
959
|
+
====
|
|
960
|
+
.Input
|
|
961
|
+
[source,liquid]
|
|
962
|
+
----
|
|
963
|
+
{{ my_flat_hash | to_cli_args: "long_equals" }}
|
|
964
|
+
----
|
|
965
|
+
|
|
966
|
+
.Output
|
|
967
|
+
[source,liquid]
|
|
968
|
+
----
|
|
969
|
+
--key1=valuu_one --key2=val_two --key3=third value
|
|
970
|
+
----
|
|
971
|
+
====
|
|
972
|
+
+
|
|
973
|
+
.Single-letter flags with values
|
|
974
|
+
====
|
|
975
|
+
.Input
|
|
976
|
+
[source,liquid]
|
|
977
|
+
----
|
|
978
|
+
{{ cli_flags_hash | to_cli_args: "short_space" }}
|
|
979
|
+
----
|
|
980
|
+
|
|
981
|
+
.Output
|
|
982
|
+
[source,liquid]
|
|
983
|
+
----
|
|
984
|
+
-k valuu_one -v val_two -o third value
|
|
985
|
+
----
|
|
986
|
+
====
|
|
987
|
+
+
|
|
988
|
+
.Positional arguments only
|
|
989
|
+
====
|
|
990
|
+
.Input
|
|
991
|
+
[source,liquid]
|
|
992
|
+
----
|
|
993
|
+
{{ my_flat_hash | to_cli_args: "positional" }}
|
|
994
|
+
----
|
|
995
|
+
|
|
996
|
+
.Output
|
|
997
|
+
[source,liquid]
|
|
998
|
+
----
|
|
999
|
+
valuu_one val_two third value
|
|
1000
|
+
----
|
|
1001
|
+
====
|
|
1002
|
+
+
|
|
1003
|
+
.Environment variable format (uppercase keys)
|
|
1004
|
+
====
|
|
1005
|
+
.Input
|
|
1006
|
+
[source,liquid]
|
|
1007
|
+
----
|
|
1008
|
+
{{ my_flat_hash | to_cli_args: "env_arg" }}
|
|
1009
|
+
----
|
|
1010
|
+
|
|
1011
|
+
.Output
|
|
1012
|
+
[source,liquid]
|
|
1013
|
+
----
|
|
1014
|
+
KEY1=valuu_one KEY2=val_two KEY3=third value
|
|
1015
|
+
----
|
|
1016
|
+
====
|
|
1017
|
+
+
|
|
1018
|
+
.Key=value format
|
|
1019
|
+
====
|
|
1020
|
+
.Input
|
|
1021
|
+
[source,liquid]
|
|
1022
|
+
----
|
|
1023
|
+
{{ my_flat_hash | to_cli_args: "keyval" }}
|
|
1024
|
+
----
|
|
1025
|
+
|
|
1026
|
+
.Output
|
|
1027
|
+
[source,liquid]
|
|
1028
|
+
----
|
|
1029
|
+
key1=valuu_one key2=val_two key3=third value
|
|
1030
|
+
----
|
|
1031
|
+
====
|
|
1032
|
+
--
|
|
1033
|
+
[[filter__to_yaml,Data objects to YAML]]
|
|
1034
|
+
Data objects to YAML (`to_yaml`)::
|
|
1035
|
+
+
|
|
1036
|
+
--
|
|
1037
|
+
Turn any parameter or data object into YAML format.
|
|
1038
|
+
|
|
1039
|
+
[horizontal]
|
|
1040
|
+
Source::: AsciiSourcerer
|
|
1041
|
+
|
|
1042
|
+
[vertical]
|
|
1043
|
+
Examples:::
|
|
1044
|
+
+
|
|
1045
|
+
====
|
|
1046
|
+
.Input
|
|
1047
|
+
[source,liquid]
|
|
1048
|
+
----
|
|
1049
|
+
{{ my_flat_hash | to_yaml }}
|
|
1050
|
+
----
|
|
1051
|
+
|
|
1052
|
+
.Output
|
|
1053
|
+
[source,liquid]
|
|
1054
|
+
----
|
|
1055
|
+
---
|
|
1056
|
+
key1: valuu_one
|
|
1057
|
+
key2: val_two
|
|
1058
|
+
key3: third value
|
|
1059
|
+
|
|
1060
|
+
----
|
|
1061
|
+
====
|
|
1062
|
+
+
|
|
1063
|
+
====
|
|
1064
|
+
.Input
|
|
1065
|
+
[source,liquid]
|
|
1066
|
+
----
|
|
1067
|
+
{{ my_flat_hash | to_yaml: "flow" }}
|
|
1068
|
+
----
|
|
1069
|
+
|
|
1070
|
+
.Output
|
|
1071
|
+
[source,liquid]
|
|
1072
|
+
----
|
|
1073
|
+
{key1: "valuu_one", key2: "val_two", key3: "third value"}
|
|
1074
|
+
----
|
|
1075
|
+
====
|
|
1076
|
+
+
|
|
1077
|
+
====
|
|
1078
|
+
.Input
|
|
1079
|
+
[source,liquid]
|
|
1080
|
+
----
|
|
1081
|
+
{{ page.tags | to_yaml }}
|
|
1082
|
+
----
|
|
1083
|
+
|
|
1084
|
+
.Output
|
|
1085
|
+
[source,liquid]
|
|
1086
|
+
----
|
|
1087
|
+
---
|
|
1088
|
+
- Seattle
|
|
1089
|
+
- Tacoma
|
|
1090
|
+
- Spokane
|
|
1091
|
+
|
|
1092
|
+
----
|
|
1093
|
+
====
|
|
1094
|
+
+
|
|
1095
|
+
====
|
|
1096
|
+
.Input
|
|
1097
|
+
[source,liquid]
|
|
1098
|
+
----
|
|
1099
|
+
{{ page.tags | to_yaml: "flow" }}
|
|
1100
|
+
----
|
|
1101
|
+
|
|
1102
|
+
.Output
|
|
1103
|
+
[source,liquid]
|
|
1104
|
+
----
|
|
1105
|
+
["Seattle", "Tacoma", "Spokane"]
|
|
1106
|
+
----
|
|
1107
|
+
====
|
|
1108
|
+
+
|
|
1109
|
+
====
|
|
1110
|
+
.Input
|
|
1111
|
+
[source,liquid]
|
|
1112
|
+
----
|
|
1113
|
+
{{ page.tags | to_yaml: "flow", "quotes" }}
|
|
1114
|
+
----
|
|
1115
|
+
|
|
1116
|
+
.Output
|
|
1117
|
+
[source,liquid]
|
|
1118
|
+
----
|
|
1119
|
+
["Seattle", "Tacoma", "Spokane"]
|
|
1120
|
+
----
|
|
1121
|
+
====
|
|
1122
|
+
--
|
|
1123
|
+
[[filter__to_json,Data objects to JSON]]
|
|
1124
|
+
Data objects to JSON (`to_json`)::
|
|
1125
|
+
+
|
|
1126
|
+
--
|
|
1127
|
+
Turn any parameter or data object into JSON format.
|
|
1128
|
+
|
|
1129
|
+
[horizontal]
|
|
1130
|
+
Source::: AsciiSourcerer
|
|
1131
|
+
|
|
1132
|
+
[vertical]
|
|
1133
|
+
Examples:::
|
|
1134
|
+
+
|
|
1135
|
+
====
|
|
1136
|
+
.Input
|
|
1137
|
+
[source,liquid]
|
|
1138
|
+
----
|
|
1139
|
+
{{ my_flat_hash | to_json }}
|
|
1140
|
+
----
|
|
1141
|
+
|
|
1142
|
+
.Output
|
|
1143
|
+
[source,liquid]
|
|
1144
|
+
----
|
|
1145
|
+
{"key1":"valuu_one","key2":"val_two","key3":"third value"}
|
|
1146
|
+
|
|
1147
|
+
----
|
|
1148
|
+
====
|
|
1149
|
+
+
|
|
1150
|
+
====
|
|
1151
|
+
.Input
|
|
1152
|
+
[source,liquid]
|
|
1153
|
+
----
|
|
1154
|
+
{{ page.tags | to_json }}
|
|
1155
|
+
----
|
|
1156
|
+
|
|
1157
|
+
.Output
|
|
1158
|
+
[source,liquid]
|
|
1159
|
+
----
|
|
1160
|
+
["Seattle","Tacoma","Spokane"]
|
|
1161
|
+
|
|
1162
|
+
----
|
|
1163
|
+
====
|
|
1164
|
+
+
|
|
1165
|
+
====
|
|
1166
|
+
.Input
|
|
1167
|
+
[source,liquid]
|
|
1168
|
+
----
|
|
1169
|
+
{{ odd_keys_hash | to_json }}
|
|
1170
|
+
----
|
|
1171
|
+
|
|
1172
|
+
.Output
|
|
1173
|
+
[source,liquid]
|
|
1174
|
+
----
|
|
1175
|
+
{"key 1":"valuu_one","$key2":"val_two","key:3":"third value"}
|
|
1176
|
+
|
|
1177
|
+
----
|
|
1178
|
+
====
|
|
1179
|
+
--
|
|
1180
|
+
// end::object-conversion[]
|
|
1181
|
+
|
|
1182
|
+
:example-capition!:
|
|
1183
|
+
|
|
1184
|
+
[[string-conversion]]
|
|
1185
|
+
== String conversion Filters
|
|
1186
|
+
|
|
1187
|
+
// tag::string-conversion[]
|
|
1188
|
+
[[filter__slugify,Slugify]]
|
|
1189
|
+
Slugify (`slugify`)::
|
|
1190
|
+
+
|
|
1191
|
+
--
|
|
1192
|
+
Convert a string into a lowercase URL "slug".
|
|
1193
|
+
|
|
1194
|
+
NOTE: This is not the Jekyll version.
|
|
1195
|
+
|
|
1196
|
+
|
|
1197
|
+
[horizontal]
|
|
1198
|
+
Source::: AsciiSourcerer
|
|
1199
|
+
|
|
1200
|
+
[vertical]
|
|
1201
|
+
Examples:::
|
|
1202
|
+
+
|
|
1203
|
+
====
|
|
1204
|
+
.Input
|
|
1205
|
+
[source,liquid]
|
|
1206
|
+
----
|
|
1207
|
+
{{ "The _config.yml file" | slugify }}
|
|
1208
|
+
----
|
|
1209
|
+
|
|
1210
|
+
.Output
|
|
1211
|
+
[source,liquid]
|
|
1212
|
+
----
|
|
1213
|
+
the-config-yml-file
|
|
1214
|
+
----
|
|
1215
|
+
====
|
|
1216
|
+
+
|
|
1217
|
+
====
|
|
1218
|
+
.Input
|
|
1219
|
+
[source,liquid]
|
|
1220
|
+
----
|
|
1221
|
+
{{ "The _config.yml file" | slugify: "_" }}
|
|
1222
|
+
----
|
|
1223
|
+
|
|
1224
|
+
.Output
|
|
1225
|
+
[source,liquid]
|
|
1226
|
+
----
|
|
1227
|
+
the_config_yml_file
|
|
1228
|
+
----
|
|
1229
|
+
====
|
|
1230
|
+
--
|
|
1231
|
+
[[filter__normalize_whitespace,Normalize Whitespace]]
|
|
1232
|
+
Normalize Whitespace (`normalize_whitespace`)::
|
|
1233
|
+
+
|
|
1234
|
+
--
|
|
1235
|
+
Replace any occurrence of whitespace with a single space.
|
|
1236
|
+
|
|
1237
|
+
[horizontal]
|
|
1238
|
+
Source::: Jekyll
|
|
1239
|
+
|
|
1240
|
+
[vertical]
|
|
1241
|
+
Examples:::
|
|
1242
|
+
+
|
|
1243
|
+
====
|
|
1244
|
+
.Input
|
|
1245
|
+
[source,liquid]
|
|
1246
|
+
----
|
|
1247
|
+
{{ "a b" | normalize_whitespace }}
|
|
1248
|
+
----
|
|
1249
|
+
|
|
1250
|
+
.Output
|
|
1251
|
+
[source,liquid]
|
|
1252
|
+
----
|
|
1253
|
+
a b
|
|
1254
|
+
----
|
|
1255
|
+
====
|
|
1256
|
+
--
|
|
1257
|
+
[[filter__capitalize,Capitalize]]
|
|
1258
|
+
Capitalize (`capitalize`)::
|
|
1259
|
+
+
|
|
1260
|
+
--
|
|
1261
|
+
Capitalizes the first character of a string and downcases the rest. Only the first character is affected, so later words are not capitalized.
|
|
1262
|
+
|
|
1263
|
+
[horizontal]
|
|
1264
|
+
Source::: Shopify
|
|
1265
|
+
|
|
1266
|
+
[vertical]
|
|
1267
|
+
Examples:::
|
|
1268
|
+
+
|
|
1269
|
+
====
|
|
1270
|
+
.Input
|
|
1271
|
+
[source,liquid]
|
|
1272
|
+
----
|
|
1273
|
+
{{ "my GREAT title" | capitalize }}
|
|
1274
|
+
----
|
|
1275
|
+
|
|
1276
|
+
.Output
|
|
1277
|
+
[source,liquid]
|
|
1278
|
+
----
|
|
1279
|
+
My great title
|
|
1280
|
+
----
|
|
1281
|
+
====
|
|
1282
|
+
--
|
|
1283
|
+
[[filter__downcase,Downcase]]
|
|
1284
|
+
Downcase (`downcase`)::
|
|
1285
|
+
+
|
|
1286
|
+
--
|
|
1287
|
+
Makes each character in a string lowercase.
|
|
1288
|
+
|
|
1289
|
+
[horizontal]
|
|
1290
|
+
Source::: Shopify
|
|
1291
|
+
|
|
1292
|
+
[vertical]
|
|
1293
|
+
Examples:::
|
|
1294
|
+
+
|
|
1295
|
+
====
|
|
1296
|
+
.Input
|
|
1297
|
+
[source,liquid]
|
|
1298
|
+
----
|
|
1299
|
+
{{ "Parker Moore" | downcase }}
|
|
1300
|
+
----
|
|
1301
|
+
|
|
1302
|
+
.Output
|
|
1303
|
+
[source,liquid]
|
|
1304
|
+
----
|
|
1305
|
+
parker moore
|
|
1306
|
+
----
|
|
1307
|
+
====
|
|
1308
|
+
--
|
|
1309
|
+
[[filter__escape,Escape]]
|
|
1310
|
+
Escape (`escape`)::
|
|
1311
|
+
+
|
|
1312
|
+
--
|
|
1313
|
+
Escapes a string's HTML-unsafe characters (so it can safely be embedded in HTML markup).
|
|
1314
|
+
|
|
1315
|
+
[horizontal]
|
|
1316
|
+
Source::: Shopify
|
|
1317
|
+
|
|
1318
|
+
[vertical]
|
|
1319
|
+
Examples:::
|
|
1320
|
+
+
|
|
1321
|
+
====
|
|
1322
|
+
.Input
|
|
1323
|
+
[source,liquid]
|
|
1324
|
+
----
|
|
1325
|
+
{{ "Have you read 'James & the Giant Peach'?" | escape }}
|
|
1326
|
+
----
|
|
1327
|
+
|
|
1328
|
+
.Output
|
|
1329
|
+
[source,liquid]
|
|
1330
|
+
----
|
|
1331
|
+
Have you read 'James & the Giant Peach'?
|
|
1332
|
+
----
|
|
1333
|
+
====
|
|
1334
|
+
--
|
|
1335
|
+
[[filter__escape_once,Escape Once]]
|
|
1336
|
+
Escape Once (`escape_once`)::
|
|
1337
|
+
+
|
|
1338
|
+
--
|
|
1339
|
+
Escapes a string's HTML-unsafe characters without double-escaping entities that are already escaped.
|
|
1340
|
+
|
|
1341
|
+
[horizontal]
|
|
1342
|
+
Source::: Shopify
|
|
1343
|
+
|
|
1344
|
+
[vertical]
|
|
1345
|
+
Examples:::
|
|
1346
|
+
+
|
|
1347
|
+
====
|
|
1348
|
+
.Input
|
|
1349
|
+
[source,liquid]
|
|
1350
|
+
----
|
|
1351
|
+
{{ "1 < 2 & 3" | escape_once }}
|
|
1352
|
+
----
|
|
1353
|
+
|
|
1354
|
+
.Output
|
|
1355
|
+
[source,liquid]
|
|
1356
|
+
----
|
|
1357
|
+
1 < 2 & 3
|
|
1358
|
+
----
|
|
1359
|
+
====
|
|
1360
|
+
+
|
|
1361
|
+
====
|
|
1362
|
+
.Input
|
|
1363
|
+
[source,liquid]
|
|
1364
|
+
----
|
|
1365
|
+
{{ "1 < 2 & 3" | escape_once }}
|
|
1366
|
+
----
|
|
1367
|
+
|
|
1368
|
+
.Output
|
|
1369
|
+
[source,liquid]
|
|
1370
|
+
----
|
|
1371
|
+
1 < 2 & 3
|
|
1372
|
+
----
|
|
1373
|
+
====
|
|
1374
|
+
--
|
|
1375
|
+
[[filter__newline_to_br,Newline to Break Tag]]
|
|
1376
|
+
Newline to Break Tag (`newline_to_br`)::
|
|
1377
|
+
+
|
|
1378
|
+
--
|
|
1379
|
+
Inserts an HTML line break (`<br />`) in front of each newline in a string.
|
|
1380
|
+
|
|
1381
|
+
[horizontal]
|
|
1382
|
+
Source::: Shopify
|
|
1383
|
+
|
|
1384
|
+
[vertical]
|
|
1385
|
+
Examples:::
|
|
1386
|
+
+
|
|
1387
|
+
====
|
|
1388
|
+
.Input
|
|
1389
|
+
[source,liquid]
|
|
1390
|
+
----
|
|
1391
|
+
{% capture s %}Hello
|
|
1392
|
+
there{% endcapture %}{{ s | newline_to_br }}
|
|
1393
|
+
|
|
1394
|
+
----
|
|
1395
|
+
|
|
1396
|
+
.Output
|
|
1397
|
+
[source,liquid]
|
|
1398
|
+
----
|
|
1399
|
+
Hello<br />
|
|
1400
|
+
there
|
|
1401
|
+
----
|
|
1402
|
+
====
|
|
1403
|
+
--
|
|
1404
|
+
[[filter__remove,Remove]]
|
|
1405
|
+
Remove (`remove`)::
|
|
1406
|
+
+
|
|
1407
|
+
--
|
|
1408
|
+
Removes every occurrence of the specified substring from a string.
|
|
1409
|
+
|
|
1410
|
+
[horizontal]
|
|
1411
|
+
Source::: Shopify
|
|
1412
|
+
|
|
1413
|
+
[vertical]
|
|
1414
|
+
Examples:::
|
|
1415
|
+
+
|
|
1416
|
+
====
|
|
1417
|
+
.Input
|
|
1418
|
+
[source,liquid]
|
|
1419
|
+
----
|
|
1420
|
+
{{ "I strained to see the train through the rain" | remove: "rain" }}
|
|
1421
|
+
----
|
|
1422
|
+
|
|
1423
|
+
.Output
|
|
1424
|
+
[source,liquid]
|
|
1425
|
+
----
|
|
1426
|
+
I sted to see the t through the
|
|
1427
|
+
----
|
|
1428
|
+
====
|
|
1429
|
+
--
|
|
1430
|
+
[[filter__remove_first,Remove First]]
|
|
1431
|
+
Remove First (`remove_first`)::
|
|
1432
|
+
+
|
|
1433
|
+
--
|
|
1434
|
+
Removes only the first occurrence of the specified substring from a string.
|
|
1435
|
+
|
|
1436
|
+
[horizontal]
|
|
1437
|
+
Source::: Shopify
|
|
1438
|
+
|
|
1439
|
+
[vertical]
|
|
1440
|
+
Examples:::
|
|
1441
|
+
+
|
|
1442
|
+
====
|
|
1443
|
+
.Input
|
|
1444
|
+
[source,liquid]
|
|
1445
|
+
----
|
|
1446
|
+
{{ "I strained to see the train through the rain" | remove_first: "rain" }}
|
|
1447
|
+
----
|
|
1448
|
+
|
|
1449
|
+
.Output
|
|
1450
|
+
[source,liquid]
|
|
1451
|
+
----
|
|
1452
|
+
I sted to see the train through the rain
|
|
1453
|
+
----
|
|
1454
|
+
====
|
|
1455
|
+
--
|
|
1456
|
+
[[filter__remove_last,Remove Last]]
|
|
1457
|
+
Remove Last (`remove_last`)::
|
|
1458
|
+
+
|
|
1459
|
+
--
|
|
1460
|
+
Removes the last instance of a substring from a string.
|
|
1461
|
+
|
|
1462
|
+
(This filter duplicates Shopify's `remove_last` filter.)
|
|
1463
|
+
|
|
1464
|
+
|
|
1465
|
+
[horizontal]
|
|
1466
|
+
Source::: AsciiSourcerer
|
|
1467
|
+
|
|
1468
|
+
[vertical]
|
|
1469
|
+
Examples:::
|
|
1470
|
+
+
|
|
1471
|
+
====
|
|
1472
|
+
.Input
|
|
1473
|
+
[source,liquid]
|
|
1474
|
+
----
|
|
1475
|
+
{{ "Ground control to Major Tom." | remove_last: "o" }}
|
|
1476
|
+
----
|
|
1477
|
+
|
|
1478
|
+
.Output
|
|
1479
|
+
[source,liquid]
|
|
1480
|
+
----
|
|
1481
|
+
Ground control to Major Tm.
|
|
1482
|
+
----
|
|
1483
|
+
====
|
|
1484
|
+
--
|
|
1485
|
+
[[filter__replace,Replace]]
|
|
1486
|
+
Replace (`replace`)::
|
|
1487
|
+
+
|
|
1488
|
+
--
|
|
1489
|
+
Replaces every occurrence of the first argument in a string with the second argument.
|
|
1490
|
+
|
|
1491
|
+
[horizontal]
|
|
1492
|
+
Source::: Shopify
|
|
1493
|
+
|
|
1494
|
+
[vertical]
|
|
1495
|
+
Examples:::
|
|
1496
|
+
+
|
|
1497
|
+
====
|
|
1498
|
+
.Input
|
|
1499
|
+
[source,liquid]
|
|
1500
|
+
----
|
|
1501
|
+
{{ "Take my protein pills and put my helmet on" | replace: "my", "your" }}
|
|
1502
|
+
----
|
|
1503
|
+
|
|
1504
|
+
.Output
|
|
1505
|
+
[source,liquid]
|
|
1506
|
+
----
|
|
1507
|
+
Take your protein pills and put your helmet on
|
|
1508
|
+
----
|
|
1509
|
+
====
|
|
1510
|
+
--
|
|
1511
|
+
[[filter__replace_first,Replace First]]
|
|
1512
|
+
Replace First (`replace_first`)::
|
|
1513
|
+
+
|
|
1514
|
+
--
|
|
1515
|
+
Replaces only the first occurrence of the first argument in a string with the second argument.
|
|
1516
|
+
|
|
1517
|
+
[horizontal]
|
|
1518
|
+
Source::: Shopify
|
|
1519
|
+
|
|
1520
|
+
[vertical]
|
|
1521
|
+
Examples:::
|
|
1522
|
+
+
|
|
1523
|
+
====
|
|
1524
|
+
.Input
|
|
1525
|
+
[source,liquid]
|
|
1526
|
+
----
|
|
1527
|
+
{{ "Take my protein pills and put my helmet on" | replace_first: "my", "your" }}
|
|
1528
|
+
----
|
|
1529
|
+
|
|
1530
|
+
.Output
|
|
1531
|
+
[source,liquid]
|
|
1532
|
+
----
|
|
1533
|
+
Take your protein pills and put my helmet on
|
|
1534
|
+
----
|
|
1535
|
+
====
|
|
1536
|
+
--
|
|
1537
|
+
[[filter__replace_last,Replace Last]]
|
|
1538
|
+
Replace Last (`replace_last`)::
|
|
1539
|
+
+
|
|
1540
|
+
--
|
|
1541
|
+
Replaces the last instance of a substring in a string with a replacement.
|
|
1542
|
+
|
|
1543
|
+
(This filter duplicates Shopify's `replace_last` filter.)
|
|
1544
|
+
|
|
1545
|
+
|
|
1546
|
+
[horizontal]
|
|
1547
|
+
Source::: AsciiSourcerer
|
|
1548
|
+
|
|
1549
|
+
[vertical]
|
|
1550
|
+
Examples:::
|
|
1551
|
+
+
|
|
1552
|
+
====
|
|
1553
|
+
.Input
|
|
1554
|
+
[source,liquid]
|
|
1555
|
+
----
|
|
1556
|
+
{{ "Ground control to Major Tom." | replace_last: "o", "0" }}
|
|
1557
|
+
----
|
|
1558
|
+
|
|
1559
|
+
.Output
|
|
1560
|
+
[source,liquid]
|
|
1561
|
+
----
|
|
1562
|
+
Ground control to Major T0m.
|
|
1563
|
+
----
|
|
1564
|
+
====
|
|
1565
|
+
--
|
|
1566
|
+
[[filter__squish,Squish]]
|
|
1567
|
+
Squish (`squish`)::
|
|
1568
|
+
+
|
|
1569
|
+
--
|
|
1570
|
+
Strips leading and trailing whitespace and collapses interior runs of
|
|
1571
|
+
whitespace to a single space.
|
|
1572
|
+
|
|
1573
|
+
(This filter duplicates Liquid 5's `squish` filter.)
|
|
1574
|
+
|
|
1575
|
+
|
|
1576
|
+
[horizontal]
|
|
1577
|
+
Source::: AsciiSourcerer
|
|
1578
|
+
|
|
1579
|
+
[vertical]
|
|
1580
|
+
Examples:::
|
|
1581
|
+
+
|
|
1582
|
+
====
|
|
1583
|
+
.Input
|
|
1584
|
+
[source,liquid]
|
|
1585
|
+
----
|
|
1586
|
+
{{ " A string that is obviously longer than 25 characters " | squish }}
|
|
1587
|
+
----
|
|
1588
|
+
|
|
1589
|
+
.Output
|
|
1590
|
+
[source,liquid]
|
|
1591
|
+
----
|
|
1592
|
+
A string that is obviously longer than 25 characters
|
|
1593
|
+
----
|
|
1594
|
+
====
|
|
1595
|
+
--
|
|
1596
|
+
[[filter__rstrip,Right Strip]]
|
|
1597
|
+
Right Strip (`rstrip`)::
|
|
1598
|
+
+
|
|
1599
|
+
--
|
|
1600
|
+
Removes whitespace (tabs, spaces, newlines) from the right side of a
|
|
1601
|
+
string. Does not affect spaces between words.
|
|
1602
|
+
|
|
1603
|
+
|
|
1604
|
+
[horizontal]
|
|
1605
|
+
Source::: Shopify
|
|
1606
|
+
|
|
1607
|
+
[vertical]
|
|
1608
|
+
Examples:::
|
|
1609
|
+
+
|
|
1610
|
+
====
|
|
1611
|
+
.Input
|
|
1612
|
+
[source,liquid]
|
|
1613
|
+
----
|
|
1614
|
+
{{ " So much room " | rstrip }}!
|
|
1615
|
+
----
|
|
1616
|
+
|
|
1617
|
+
.Output
|
|
1618
|
+
[source,liquid]
|
|
1619
|
+
----
|
|
1620
|
+
So much room!
|
|
1621
|
+
----
|
|
1622
|
+
====
|
|
1623
|
+
--
|
|
1624
|
+
[[filter__strip,Strip]]
|
|
1625
|
+
Strip (`strip`)::
|
|
1626
|
+
+
|
|
1627
|
+
--
|
|
1628
|
+
Removes whitespace (tabs, spaces, newlines) from both sides of a
|
|
1629
|
+
string. Does not affect spaces between words.
|
|
1630
|
+
|
|
1631
|
+
|
|
1632
|
+
[horizontal]
|
|
1633
|
+
Source::: Shopify
|
|
1634
|
+
|
|
1635
|
+
[vertical]
|
|
1636
|
+
Examples:::
|
|
1637
|
+
+
|
|
1638
|
+
====
|
|
1639
|
+
.Input
|
|
1640
|
+
[source,liquid]
|
|
1641
|
+
----
|
|
1642
|
+
{{ " So much room " | strip }}!
|
|
1643
|
+
----
|
|
1644
|
+
|
|
1645
|
+
.Output
|
|
1646
|
+
[source,liquid]
|
|
1647
|
+
----
|
|
1648
|
+
So much room!
|
|
1649
|
+
----
|
|
1650
|
+
====
|
|
1651
|
+
--
|
|
1652
|
+
[[filter__strip_html,Strip HTML]]
|
|
1653
|
+
Strip HTML (`strip_html`)::
|
|
1654
|
+
+
|
|
1655
|
+
--
|
|
1656
|
+
Removes any HTML tags from a string.
|
|
1657
|
+
|
|
1658
|
+
[horizontal]
|
|
1659
|
+
Source::: Shopify
|
|
1660
|
+
|
|
1661
|
+
[vertical]
|
|
1662
|
+
Examples:::
|
|
1663
|
+
+
|
|
1664
|
+
====
|
|
1665
|
+
.Input
|
|
1666
|
+
[source,liquid]
|
|
1667
|
+
----
|
|
1668
|
+
{{ "Have <em>you</em> read <strong>Ulysses</strong>?" | strip_html }}
|
|
1669
|
+
----
|
|
1670
|
+
|
|
1671
|
+
.Output
|
|
1672
|
+
[source,liquid]
|
|
1673
|
+
----
|
|
1674
|
+
Have you read Ulysses?
|
|
1675
|
+
----
|
|
1676
|
+
====
|
|
1677
|
+
--
|
|
1678
|
+
[[filter__strip_newlines,Strip Newlines]]
|
|
1679
|
+
Strip Newlines (`strip_newlines`)::
|
|
1680
|
+
+
|
|
1681
|
+
--
|
|
1682
|
+
Removes any newline characters from a string.
|
|
1683
|
+
|
|
1684
|
+
[horizontal]
|
|
1685
|
+
Source::: Shopify
|
|
1686
|
+
|
|
1687
|
+
[vertical]
|
|
1688
|
+
Examples:::
|
|
1689
|
+
+
|
|
1690
|
+
====
|
|
1691
|
+
.Input
|
|
1692
|
+
[source,liquid]
|
|
1693
|
+
----
|
|
1694
|
+
{% capture s %}Hello
|
|
1695
|
+
there{% endcapture %}{{ s | strip_newlines }}
|
|
1696
|
+
|
|
1697
|
+
----
|
|
1698
|
+
|
|
1699
|
+
.Output
|
|
1700
|
+
[source,liquid]
|
|
1701
|
+
----
|
|
1702
|
+
Hellothere
|
|
1703
|
+
----
|
|
1704
|
+
====
|
|
1705
|
+
--
|
|
1706
|
+
[[filter__truncatewords,Truncate Words]]
|
|
1707
|
+
Truncate Words (`truncatewords`)::
|
|
1708
|
+
+
|
|
1709
|
+
--
|
|
1710
|
+
Shortens a string to the given number of words. If shortened, an
|
|
1711
|
+
ellipsis (`...`) is appended; pass a second argument to use a
|
|
1712
|
+
different (or no) ellipsis.
|
|
1713
|
+
|
|
1714
|
+
|
|
1715
|
+
[horizontal]
|
|
1716
|
+
Source::: Shopify
|
|
1717
|
+
|
|
1718
|
+
[vertical]
|
|
1719
|
+
Examples:::
|
|
1720
|
+
+
|
|
1721
|
+
====
|
|
1722
|
+
.Input
|
|
1723
|
+
[source,liquid]
|
|
1724
|
+
----
|
|
1725
|
+
{{ "Ground control to Major Tom." | truncatewords: 3 }}
|
|
1726
|
+
----
|
|
1727
|
+
|
|
1728
|
+
.Output
|
|
1729
|
+
[source,liquid]
|
|
1730
|
+
----
|
|
1731
|
+
Ground control to...
|
|
1732
|
+
----
|
|
1733
|
+
====
|
|
1734
|
+
--
|
|
1735
|
+
[[filter__upcase,Upcase]]
|
|
1736
|
+
Upcase (`upcase`)::
|
|
1737
|
+
+
|
|
1738
|
+
--
|
|
1739
|
+
Makes each character in a string uppercase.
|
|
1740
|
+
|
|
1741
|
+
[horizontal]
|
|
1742
|
+
Source::: Shopify
|
|
1743
|
+
|
|
1744
|
+
[vertical]
|
|
1745
|
+
Examples:::
|
|
1746
|
+
+
|
|
1747
|
+
====
|
|
1748
|
+
.Input
|
|
1749
|
+
[source,liquid]
|
|
1750
|
+
----
|
|
1751
|
+
{{ "Parker Moore" | upcase }}
|
|
1752
|
+
----
|
|
1753
|
+
|
|
1754
|
+
.Output
|
|
1755
|
+
[source,liquid]
|
|
1756
|
+
----
|
|
1757
|
+
PARKER MOORE
|
|
1758
|
+
----
|
|
1759
|
+
====
|
|
1760
|
+
--
|
|
1761
|
+
[[filter__wrap,Wrap]]
|
|
1762
|
+
Wrap (`wrap`)::
|
|
1763
|
+
+
|
|
1764
|
+
--
|
|
1765
|
+
|
|
1766
|
+
|
|
1767
|
+
[horizontal]
|
|
1768
|
+
Source::: AsciiSourcerer
|
|
1769
|
+
|
|
1770
|
+
[vertical]
|
|
1771
|
+
Examples:::
|
|
1772
|
+
+
|
|
1773
|
+
====
|
|
1774
|
+
.Input
|
|
1775
|
+
[source,liquid]
|
|
1776
|
+
----
|
|
1777
|
+
{{ "A string that is obviously longer than 25 characters" | wrap: 25 }}
|
|
1778
|
+
----
|
|
1779
|
+
|
|
1780
|
+
.Output
|
|
1781
|
+
[source,liquid]
|
|
1782
|
+
----
|
|
1783
|
+
A string that is
|
|
1784
|
+
obviously longer than 25
|
|
1785
|
+
characters
|
|
1786
|
+
|
|
1787
|
+
----
|
|
1788
|
+
====
|
|
1789
|
+
--
|
|
1790
|
+
[[filter__commentwrap,Comment Wrap]]
|
|
1791
|
+
Comment Wrap (`commentwrap`)::
|
|
1792
|
+
+
|
|
1793
|
+
--
|
|
1794
|
+
|
|
1795
|
+
|
|
1796
|
+
[horizontal]
|
|
1797
|
+
Source::: AsciiSourcerer
|
|
1798
|
+
|
|
1799
|
+
[vertical]
|
|
1800
|
+
Examples:::
|
|
1801
|
+
+
|
|
1802
|
+
====
|
|
1803
|
+
.Input
|
|
1804
|
+
[source,liquid]
|
|
1805
|
+
----
|
|
1806
|
+
{{ comment_text | commentwrap: 25, "// " }}
|
|
1807
|
+
----
|
|
1808
|
+
|
|
1809
|
+
.Output
|
|
1810
|
+
[source,liquid]
|
|
1811
|
+
----
|
|
1812
|
+
// A string that is
|
|
1813
|
+
// obviously longer than 25
|
|
1814
|
+
// characters
|
|
1815
|
+
|
|
1816
|
+
----
|
|
1817
|
+
====
|
|
1818
|
+
+
|
|
1819
|
+
====
|
|
1820
|
+
.Input
|
|
1821
|
+
[source,liquid]
|
|
1822
|
+
----
|
|
1823
|
+
{{ comment_text | commentwrap: 25, "xml" }}
|
|
1824
|
+
----
|
|
1825
|
+
|
|
1826
|
+
.Output
|
|
1827
|
+
[source,liquid]
|
|
1828
|
+
----
|
|
1829
|
+
<!-- A string that is
|
|
1830
|
+
obviously longer than 25
|
|
1831
|
+
characters -->
|
|
1832
|
+
|
|
1833
|
+
----
|
|
1834
|
+
====
|
|
1835
|
+
+
|
|
1836
|
+
====
|
|
1837
|
+
.Input
|
|
1838
|
+
[source,liquid]
|
|
1839
|
+
----
|
|
1840
|
+
{{ comment_text | commentwrap: 25, "/*|*/" }}
|
|
1841
|
+
----
|
|
1842
|
+
|
|
1843
|
+
.Output
|
|
1844
|
+
[source,liquid]
|
|
1845
|
+
----
|
|
1846
|
+
/* A string that is
|
|
1847
|
+
obviously longer than 25
|
|
1848
|
+
characters
|
|
1849
|
+
*/
|
|
1850
|
+
|
|
1851
|
+
----
|
|
1852
|
+
====
|
|
1853
|
+
--
|
|
1854
|
+
[[filter__relative_url,Relative URL]]
|
|
1855
|
+
Relative URL (`relative_url`)::
|
|
1856
|
+
+
|
|
1857
|
+
--
|
|
1858
|
+
Prepend `baseurl` config value to the input to convert a URL path into a relative URL.
|
|
1859
|
+
This is recommended for a site that is hosted on a subpath of a domain.
|
|
1860
|
+
|
|
1861
|
+
NOTE: Requires registration of a `site.baseurl` object outside `jekyll build` contexts.
|
|
1862
|
+
|
|
1863
|
+
|
|
1864
|
+
[horizontal]
|
|
1865
|
+
Source::: Jekyll
|
|
1866
|
+
|
|
1867
|
+
[vertical]
|
|
1868
|
+
Examples:::
|
|
1869
|
+
+
|
|
1870
|
+
====
|
|
1871
|
+
.Input
|
|
1872
|
+
[source,liquid]
|
|
1873
|
+
----
|
|
1874
|
+
{{ "test-path" | relative_url }}
|
|
1875
|
+
----
|
|
1876
|
+
|
|
1877
|
+
.Output
|
|
1878
|
+
[source,liquid]
|
|
1879
|
+
----
|
|
1880
|
+
/docs/test-path
|
|
1881
|
+
----
|
|
1882
|
+
====
|
|
1883
|
+
--
|
|
1884
|
+
[[filter__absolute_url,Absolute URL]]
|
|
1885
|
+
Absolute URL (`absolute_url`)::
|
|
1886
|
+
+
|
|
1887
|
+
--
|
|
1888
|
+
Prepend `url` and `baseurl` values to the input to convert a URL path to an absolute URL.
|
|
1889
|
+
|
|
1890
|
+
NOTE: Requires registration of `site.baseurl` and `site.url` objects outside `jekyll build` contexts.
|
|
1891
|
+
|
|
1892
|
+
|
|
1893
|
+
[horizontal]
|
|
1894
|
+
Source::: Jekyll
|
|
1895
|
+
|
|
1896
|
+
[vertical]
|
|
1897
|
+
Examples:::
|
|
1898
|
+
+
|
|
1899
|
+
====
|
|
1900
|
+
.Input
|
|
1901
|
+
[source,liquid]
|
|
1902
|
+
----
|
|
1903
|
+
{{ "test-path" | absolute_url }}
|
|
1904
|
+
----
|
|
1905
|
+
|
|
1906
|
+
.Output
|
|
1907
|
+
[source,liquid]
|
|
1908
|
+
----
|
|
1909
|
+
https://example.com/docs/test-path
|
|
1910
|
+
----
|
|
1911
|
+
====
|
|
1912
|
+
--
|
|
1913
|
+
[[filter__markdownify,Markdownify]]
|
|
1914
|
+
Markdownify (`markdownify`)::
|
|
1915
|
+
+
|
|
1916
|
+
--
|
|
1917
|
+
Converts a Markdown string to HTML.
|
|
1918
|
+
|
|
1919
|
+
[horizontal]
|
|
1920
|
+
Source::: Jekyll
|
|
1921
|
+
|
|
1922
|
+
[vertical]
|
|
1923
|
+
Examples:::
|
|
1924
|
+
+
|
|
1925
|
+
====
|
|
1926
|
+
.Input
|
|
1927
|
+
[source,liquid]
|
|
1928
|
+
----
|
|
1929
|
+
{{ "Test with **bold** and a [link](https://example.com)." | markdownify }}
|
|
1930
|
+
----
|
|
1931
|
+
|
|
1932
|
+
.Output
|
|
1933
|
+
[source,liquid]
|
|
1934
|
+
----
|
|
1935
|
+
<p>Test with <strong>bold</strong> and a <a href="https://example.com">link</a>.</p>
|
|
1936
|
+
----
|
|
1937
|
+
====
|
|
1938
|
+
--
|
|
1939
|
+
[[filter__smartify,Smartify]]
|
|
1940
|
+
Smartify (`smartify`)::
|
|
1941
|
+
+
|
|
1942
|
+
--
|
|
1943
|
+
Convert "quotes" into “smart quotes.”
|
|
1944
|
+
|
|
1945
|
+
[horizontal]
|
|
1946
|
+
Source::: Jekyll
|
|
1947
|
+
|
|
1948
|
+
[vertical]
|
|
1949
|
+
Examples:::
|
|
1950
|
+
+
|
|
1951
|
+
====
|
|
1952
|
+
.Input
|
|
1953
|
+
[source,liquid]
|
|
1954
|
+
----
|
|
1955
|
+
{{ 'He said, "Hello!"' | smartify }}
|
|
1956
|
+
|
|
1957
|
+
----
|
|
1958
|
+
|
|
1959
|
+
.Output
|
|
1960
|
+
[source,liquid]
|
|
1961
|
+
----
|
|
1962
|
+
He said, “Hello!”
|
|
1963
|
+
----
|
|
1964
|
+
====
|
|
1965
|
+
--
|
|
1966
|
+
[[filter__sassify,Sassify]]
|
|
1967
|
+
Sassify (`sassify`)::
|
|
1968
|
+
+
|
|
1969
|
+
--
|
|
1970
|
+
Convert an indented-syntax Sass string into CSS.
|
|
1971
|
+
|
|
1972
|
+
[horizontal]
|
|
1973
|
+
Source::: Jekyll
|
|
1974
|
+
|
|
1975
|
+
[vertical]
|
|
1976
|
+
Examples:::
|
|
1977
|
+
+
|
|
1978
|
+
====
|
|
1979
|
+
.Input
|
|
1980
|
+
[source,liquid]
|
|
1981
|
+
----
|
|
1982
|
+
{{ sass_text | sassify }}
|
|
1983
|
+
|
|
1984
|
+
----
|
|
1985
|
+
|
|
1986
|
+
.Output
|
|
1987
|
+
[source,liquid]
|
|
1988
|
+
----
|
|
1989
|
+
body {
|
|
1990
|
+
color: red;
|
|
1991
|
+
}
|
|
1992
|
+
|
|
1993
|
+
----
|
|
1994
|
+
====
|
|
1995
|
+
--
|
|
1996
|
+
[[filter__scssify,Scssify]]
|
|
1997
|
+
Scssify (`scssify`)::
|
|
1998
|
+
+
|
|
1999
|
+
--
|
|
2000
|
+
Convert a SCSS-formatted (brace/semicolon syntax) string into CSS.
|
|
2001
|
+
|
|
2002
|
+
[horizontal]
|
|
2003
|
+
Source::: Jekyll
|
|
2004
|
+
|
|
2005
|
+
[vertical]
|
|
2006
|
+
Examples:::
|
|
2007
|
+
+
|
|
2008
|
+
====
|
|
2009
|
+
.Input
|
|
2010
|
+
[source,liquid]
|
|
2011
|
+
----
|
|
2012
|
+
{{ scss_text | scssify }}
|
|
2013
|
+
|
|
2014
|
+
----
|
|
2015
|
+
|
|
2016
|
+
.Output
|
|
2017
|
+
[source,liquid]
|
|
2018
|
+
----
|
|
2019
|
+
body {
|
|
2020
|
+
color: red;
|
|
2021
|
+
}
|
|
2022
|
+
|
|
2023
|
+
----
|
|
2024
|
+
====
|
|
2025
|
+
--
|
|
2026
|
+
[[filter__asciidocify,AsciiDocify]]
|
|
2027
|
+
AsciiDocify (`asciidocify`)::
|
|
2028
|
+
+
|
|
2029
|
+
--
|
|
2030
|
+
Convert an AsciiDoc string to HTML, with or without paragraphing.
|
|
2031
|
+
|
|
2032
|
+
[horizontal]
|
|
2033
|
+
Source::: jekyll-asciidoc
|
|
2034
|
+
|
|
2035
|
+
[vertical]
|
|
2036
|
+
Examples:::
|
|
2037
|
+
+
|
|
2038
|
+
====
|
|
2039
|
+
.Input
|
|
2040
|
+
[source,liquid]
|
|
2041
|
+
----
|
|
2042
|
+
{{ "Test with *bold* and a http://example.com[link]." | asciidocify }}
|
|
2043
|
+
|
|
2044
|
+
----
|
|
2045
|
+
|
|
2046
|
+
.Output
|
|
2047
|
+
[source,liquid]
|
|
2048
|
+
----
|
|
2049
|
+
<div class="paragraph">
|
|
2050
|
+
<p>Test with <strong>bold</strong> and a <a href="http://example.com">link</a>.</p>
|
|
2051
|
+
</div>
|
|
2052
|
+
|
|
2053
|
+
----
|
|
2054
|
+
====
|
|
2055
|
+
+
|
|
2056
|
+
====
|
|
2057
|
+
.Input
|
|
2058
|
+
[source,liquid]
|
|
2059
|
+
----
|
|
2060
|
+
{{ "Test with *bold* and a http://example.com[link]." | asciidocify: "inline" }}
|
|
2061
|
+
|
|
2062
|
+
----
|
|
2063
|
+
|
|
2064
|
+
.Output
|
|
2065
|
+
[source,liquid]
|
|
2066
|
+
----
|
|
2067
|
+
Test with <strong>bold</strong> and a <a href="http://example.com">link</a>.
|
|
2068
|
+
|
|
2069
|
+
----
|
|
2070
|
+
====
|
|
2071
|
+
--
|
|
2072
|
+
// end::string-conversion[]
|
|
2073
|
+
|
|
2074
|
+
:example-capition!:
|
|
2075
|
+
|
|
2076
|
+
[[array-management]]
|
|
2077
|
+
== Array management Filters
|
|
2078
|
+
|
|
2079
|
+
// tag::array-management[]
|
|
2080
|
+
[[filter__push,Push]]
|
|
2081
|
+
Push (`push`)::
|
|
2082
|
+
+
|
|
2083
|
+
--
|
|
2084
|
+
Insert an item at the end of an array
|
|
2085
|
+
|
|
2086
|
+
|
|
2087
|
+
[horizontal]
|
|
2088
|
+
Source::: Jekyll
|
|
2089
|
+
|
|
2090
|
+
[vertical]
|
|
2091
|
+
Examples:::
|
|
2092
|
+
+
|
|
2093
|
+
====
|
|
2094
|
+
.Input
|
|
2095
|
+
[source,liquid]
|
|
2096
|
+
----
|
|
2097
|
+
{{ page.tags | push: "Spokane" | inspect }}
|
|
2098
|
+
----
|
|
2099
|
+
|
|
2100
|
+
.Output
|
|
2101
|
+
[source,liquid]
|
|
2102
|
+
----
|
|
2103
|
+
["Seattle", "Tacoma", "Spokane", "Spokane"]
|
|
2104
|
+
----
|
|
2105
|
+
====
|
|
2106
|
+
--
|
|
2107
|
+
[[filter__pop,Pop]]
|
|
2108
|
+
Pop (`pop`)::
|
|
2109
|
+
+
|
|
2110
|
+
--
|
|
2111
|
+
Remove an item from the end of an array
|
|
2112
|
+
|
|
2113
|
+
|
|
2114
|
+
[horizontal]
|
|
2115
|
+
Source::: Jekyll
|
|
2116
|
+
|
|
2117
|
+
[vertical]
|
|
2118
|
+
Examples:::
|
|
2119
|
+
+
|
|
2120
|
+
====
|
|
2121
|
+
.Input
|
|
2122
|
+
[source,liquid]
|
|
2123
|
+
----
|
|
2124
|
+
{{ page.tags | pop | inspect }}
|
|
2125
|
+
----
|
|
2126
|
+
|
|
2127
|
+
.Output
|
|
2128
|
+
[source,liquid]
|
|
2129
|
+
----
|
|
2130
|
+
["Seattle", "Tacoma"]
|
|
2131
|
+
----
|
|
2132
|
+
====
|
|
2133
|
+
--
|
|
2134
|
+
[[filter__shift,Shift]]
|
|
2135
|
+
Shift (`shift`)::
|
|
2136
|
+
+
|
|
2137
|
+
--
|
|
2138
|
+
Remove an item from the beginning of an array
|
|
2139
|
+
|
|
2140
|
+
|
|
2141
|
+
[horizontal]
|
|
2142
|
+
Source::: Jekyll
|
|
2143
|
+
|
|
2144
|
+
[vertical]
|
|
2145
|
+
Examples:::
|
|
2146
|
+
+
|
|
2147
|
+
====
|
|
2148
|
+
.Input
|
|
2149
|
+
[source,liquid]
|
|
2150
|
+
----
|
|
2151
|
+
{{ page.tags | shift | inspect }}
|
|
2152
|
+
----
|
|
2153
|
+
|
|
2154
|
+
.Output
|
|
2155
|
+
[source,liquid]
|
|
2156
|
+
----
|
|
2157
|
+
["Tacoma", "Spokane"]
|
|
2158
|
+
----
|
|
2159
|
+
====
|
|
2160
|
+
--
|
|
2161
|
+
[[filter__unshift,Unshift]]
|
|
2162
|
+
Unshift (`unshift`)::
|
|
2163
|
+
+
|
|
2164
|
+
--
|
|
2165
|
+
Insert an item at the beginning of an array
|
|
2166
|
+
|
|
2167
|
+
|
|
2168
|
+
[horizontal]
|
|
2169
|
+
Source::: Jekyll
|
|
2170
|
+
|
|
2171
|
+
[vertical]
|
|
2172
|
+
Examples:::
|
|
2173
|
+
+
|
|
2174
|
+
====
|
|
2175
|
+
.Input
|
|
2176
|
+
[source,liquid]
|
|
2177
|
+
----
|
|
2178
|
+
{{ page.tags | unshift: "Olympia" | inspect }}
|
|
2179
|
+
----
|
|
2180
|
+
|
|
2181
|
+
.Output
|
|
2182
|
+
[source,liquid]
|
|
2183
|
+
----
|
|
2184
|
+
["Olympia", "Seattle", "Tacoma", "Spokane"]
|
|
2185
|
+
----
|
|
2186
|
+
====
|
|
2187
|
+
--
|
|
2188
|
+
[[filter__compact,Compact]]
|
|
2189
|
+
Compact (`compact`)::
|
|
2190
|
+
+
|
|
2191
|
+
--
|
|
2192
|
+
Removes any `nil` values from an array.
|
|
2193
|
+
|
|
2194
|
+
[horizontal]
|
|
2195
|
+
Source::: Shopify
|
|
2196
|
+
|
|
2197
|
+
[vertical]
|
|
2198
|
+
Examples:::
|
|
2199
|
+
+
|
|
2200
|
+
====
|
|
2201
|
+
.Input
|
|
2202
|
+
[source,liquid]
|
|
2203
|
+
----
|
|
2204
|
+
{% assign compacted = mixed_array | compact %}
|
|
2205
|
+
{{ compacted | join: "," }}
|
|
2206
|
+
|
|
2207
|
+
----
|
|
2208
|
+
|
|
2209
|
+
.Output
|
|
2210
|
+
[source,liquid]
|
|
2211
|
+
----
|
|
2212
|
+
a,b,c
|
|
2213
|
+
----
|
|
2214
|
+
====
|
|
2215
|
+
--
|
|
2216
|
+
[[filter__concat,Concatenate]]
|
|
2217
|
+
Concatenate (`concat`)::
|
|
2218
|
+
+
|
|
2219
|
+
--
|
|
2220
|
+
Concatenates (joins together) multiple arrays. The resulting array contains all the items from the input arrays.
|
|
2221
|
+
|
|
2222
|
+
[horizontal]
|
|
2223
|
+
Source::: Shopify
|
|
2224
|
+
|
|
2225
|
+
[vertical]
|
|
2226
|
+
Examples:::
|
|
2227
|
+
+
|
|
2228
|
+
====
|
|
2229
|
+
.Input
|
|
2230
|
+
[source,liquid]
|
|
2231
|
+
----
|
|
2232
|
+
{% assign fruits = "apples, oranges" | split: ", " %}
|
|
2233
|
+
{% assign veggies = "carrots, turnips" | split: ", " %}
|
|
2234
|
+
{{ fruits | concat: veggies | join: "," }}
|
|
2235
|
+
|
|
2236
|
+
----
|
|
2237
|
+
|
|
2238
|
+
.Output
|
|
2239
|
+
[source,liquid]
|
|
2240
|
+
----
|
|
2241
|
+
apples,oranges,carrots,turnips
|
|
2242
|
+
----
|
|
2243
|
+
====
|
|
2244
|
+
--
|
|
2245
|
+
[[filter__uniq,Uniq]]
|
|
2246
|
+
Uniq (`uniq`)::
|
|
2247
|
+
+
|
|
2248
|
+
--
|
|
2249
|
+
Removes any duplicate items from an array, preserving the first occurrence's order.
|
|
2250
|
+
|
|
2251
|
+
[horizontal]
|
|
2252
|
+
Source::: Shopify
|
|
2253
|
+
|
|
2254
|
+
[vertical]
|
|
2255
|
+
Examples:::
|
|
2256
|
+
+
|
|
2257
|
+
====
|
|
2258
|
+
.Input
|
|
2259
|
+
[source,liquid]
|
|
2260
|
+
----
|
|
2261
|
+
{% assign arr = "ants, bugs, bees, bugs, ants" | split: ", " %}
|
|
2262
|
+
{{ arr | uniq | join: "," }}
|
|
2263
|
+
|
|
2264
|
+
----
|
|
2265
|
+
|
|
2266
|
+
.Output
|
|
2267
|
+
[source,liquid]
|
|
2268
|
+
----
|
|
2269
|
+
ants,bugs,bees
|
|
2270
|
+
----
|
|
2271
|
+
====
|
|
2272
|
+
--
|
|
2273
|
+
[[filter__store_list_concat,Metastore list concat]]
|
|
2274
|
+
Metastore list concat (`store_list_concat`)::
|
|
2275
|
+
+
|
|
2276
|
+
--
|
|
2277
|
+
Concatenates each Array-formatted value of the same-named property across all nodes in an Array of Hashes (Metastore).
|
|
2278
|
+
Accepts an Array of Hashes and the keyname of a property to collect from.
|
|
2279
|
+
|
|
2280
|
+
|
|
2281
|
+
[horizontal]
|
|
2282
|
+
Source::: AsciiSourcerer
|
|
2283
|
+
|
|
2284
|
+
[vertical]
|
|
2285
|
+
Examples:::
|
|
2286
|
+
+
|
|
2287
|
+
====
|
|
2288
|
+
.Input
|
|
2289
|
+
[source,liquid]
|
|
2290
|
+
----
|
|
2291
|
+
{{ data.metastore | store_list_concat: "children" | jsonify }}
|
|
2292
|
+
|
|
2293
|
+
----
|
|
2294
|
+
|
|
2295
|
+
.Output
|
|
2296
|
+
[source,liquid]
|
|
2297
|
+
----
|
|
2298
|
+
["child1","child2","child3","child4","child5","child6"]
|
|
2299
|
+
----
|
|
2300
|
+
====
|
|
2301
|
+
--
|
|
2302
|
+
[[filter__store_list_dupes,Metastore list duplicates]]
|
|
2303
|
+
Metastore list duplicates (`store_list_dupes`)::
|
|
2304
|
+
+
|
|
2305
|
+
--
|
|
2306
|
+
Returns a list of duplicate items among multiple Arrays across multiple same-named properties in an Array of Hashes (Metastore).
|
|
2307
|
+
Accepts an Array of Hashes and the keyname of a Scalar property to check; returns the names of duplicate properties.
|
|
2308
|
+
|
|
2309
|
+
|
|
2310
|
+
[horizontal]
|
|
2311
|
+
Source::: AsciiSourcerer
|
|
2312
|
+
|
|
2313
|
+
[vertical]
|
|
2314
|
+
Examples:::
|
|
2315
|
+
+
|
|
2316
|
+
====
|
|
2317
|
+
.Input
|
|
2318
|
+
[source,liquid]
|
|
2319
|
+
----
|
|
2320
|
+
{{ data.metastore | store_list_dupes: "children" | jsonify }}
|
|
2321
|
+
|
|
2322
|
+
----
|
|
2323
|
+
|
|
2324
|
+
.Output
|
|
2325
|
+
[source,liquid]
|
|
2326
|
+
----
|
|
2327
|
+
["child1"]
|
|
2328
|
+
----
|
|
2329
|
+
====
|
|
2330
|
+
--
|
|
2331
|
+
// end::array-management[]
|
|
2332
|
+
|
|
2333
|
+
:example-capition!:
|
|
2334
|
+
|
|
2335
|
+
[[object-analysis]]
|
|
2336
|
+
== Object analysis Filters
|
|
2337
|
+
|
|
2338
|
+
// tag::object-analysis[]
|
|
2339
|
+
[[filter__inspect,Inspect]]
|
|
2340
|
+
Inspect (`inspect`)::
|
|
2341
|
+
+
|
|
2342
|
+
--
|
|
2343
|
+
Convert an object into its String representation for debugging.
|
|
2344
|
+
Overrides Jekyll's `inspect` filter, adding an optional `format` argument:
|
|
2345
|
+
`html` (default) reproduces Jekyll's own behavior exactly (an HTML-escaped
|
|
2346
|
+
`Object#inspect` string, quotes become `"`); `yaml` and `json` render
|
|
2347
|
+
the object in those formats instead.
|
|
2348
|
+
|
|
2349
|
+
|
|
2350
|
+
[horizontal]
|
|
2351
|
+
Source::: AsciiSourcerer
|
|
2352
|
+
|
|
2353
|
+
[vertical]
|
|
2354
|
+
Examples:::
|
|
2355
|
+
+
|
|
2356
|
+
.Default (html) format, matches Jekyll's inspect
|
|
2357
|
+
====
|
|
2358
|
+
.Input
|
|
2359
|
+
[source,liquid]
|
|
2360
|
+
----
|
|
2361
|
+
{{ tags_array | inspect }}
|
|
2362
|
+
----
|
|
2363
|
+
|
|
2364
|
+
.Output
|
|
2365
|
+
[source,liquid]
|
|
2366
|
+
----
|
|
2367
|
+
["foo", "bar", "baz"]
|
|
2368
|
+
----
|
|
2369
|
+
====
|
|
2370
|
+
+
|
|
2371
|
+
.YAML format
|
|
2372
|
+
====
|
|
2373
|
+
.Input
|
|
2374
|
+
[source,liquid]
|
|
2375
|
+
----
|
|
2376
|
+
{{ tags_array | inspect: "yaml" }}
|
|
2377
|
+
|
|
2378
|
+
----
|
|
2379
|
+
|
|
2380
|
+
.Output
|
|
2381
|
+
[source,liquid]
|
|
2382
|
+
----
|
|
2383
|
+
---
|
|
2384
|
+
- foo
|
|
2385
|
+
- bar
|
|
2386
|
+
- baz
|
|
2387
|
+
|
|
2388
|
+
----
|
|
2389
|
+
====
|
|
2390
|
+
+
|
|
2391
|
+
.JSON format
|
|
2392
|
+
====
|
|
2393
|
+
.Input
|
|
2394
|
+
[source,liquid]
|
|
2395
|
+
----
|
|
2396
|
+
{{ tags_array | inspect: "json" }}
|
|
2397
|
+
----
|
|
2398
|
+
|
|
2399
|
+
.Output
|
|
2400
|
+
[source,liquid]
|
|
2401
|
+
----
|
|
2402
|
+
["foo","bar","baz"]
|
|
2403
|
+
----
|
|
2404
|
+
====
|
|
2405
|
+
--
|
|
2406
|
+
[[filter__size,Size]]
|
|
2407
|
+
Size (`size`)::
|
|
2408
|
+
+
|
|
2409
|
+
--
|
|
2410
|
+
Returns the number of characters in a string, or the number of items in an array.
|
|
2411
|
+
|
|
2412
|
+
[horizontal]
|
|
2413
|
+
Source::: Shopify
|
|
2414
|
+
|
|
2415
|
+
[vertical]
|
|
2416
|
+
Examples:::
|
|
2417
|
+
+
|
|
2418
|
+
====
|
|
2419
|
+
.Input
|
|
2420
|
+
[source,liquid]
|
|
2421
|
+
----
|
|
2422
|
+
{{ "Ground control to Major Tom." | size }}
|
|
2423
|
+
----
|
|
2424
|
+
|
|
2425
|
+
.Output
|
|
2426
|
+
[source,liquid]
|
|
2427
|
+
----
|
|
2428
|
+
28
|
|
2429
|
+
----
|
|
2430
|
+
====
|
|
2431
|
+
--
|
|
2432
|
+
[[filter__holds_liquid,Holds Liquid]]
|
|
2433
|
+
Holds Liquid (`holds_liquid`)::
|
|
2434
|
+
+
|
|
2435
|
+
--
|
|
2436
|
+
Returns true if a snippet of text contains Liquid markup tags.
|
|
2437
|
+
|
|
2438
|
+
[horizontal]
|
|
2439
|
+
Source::: AsciiSourcerer
|
|
2440
|
+
|
|
2441
|
+
[vertical]
|
|
2442
|
+
Examples:::
|
|
2443
|
+
+
|
|
2444
|
+
====
|
|
2445
|
+
.Input
|
|
2446
|
+
[source,liquid]
|
|
2447
|
+
----
|
|
2448
|
+
{{ liquidy_text | holds_liquid }}
|
|
2449
|
+
|
|
2450
|
+
----
|
|
2451
|
+
|
|
2452
|
+
.Output
|
|
2453
|
+
[source,liquid]
|
|
2454
|
+
----
|
|
2455
|
+
true
|
|
2456
|
+
----
|
|
2457
|
+
====
|
|
2458
|
+
+
|
|
2459
|
+
====
|
|
2460
|
+
.Input
|
|
2461
|
+
[source,liquid]
|
|
2462
|
+
----
|
|
2463
|
+
{{ "This is just text." | holds_liquid }}
|
|
2464
|
+
|
|
2465
|
+
----
|
|
2466
|
+
|
|
2467
|
+
.Output
|
|
2468
|
+
[source,liquid]
|
|
2469
|
+
----
|
|
2470
|
+
false
|
|
2471
|
+
----
|
|
2472
|
+
====
|
|
2473
|
+
--
|
|
2474
|
+
// end::object-analysis[]
|
|
2475
|
+
|
|
2476
|
+
:example-capition!:
|
|
2477
|
+
|
|
2478
|
+
[[math]]
|
|
2479
|
+
== Math Filters
|
|
2480
|
+
|
|
2481
|
+
// tag::math[]
|
|
2482
|
+
[[filter__abs,Absolute Value]]
|
|
2483
|
+
Absolute Value (`abs`)::
|
|
2484
|
+
+
|
|
2485
|
+
--
|
|
2486
|
+
Returns the absolute value of a number.
|
|
2487
|
+
|
|
2488
|
+
[horizontal]
|
|
2489
|
+
Source::: Shopify
|
|
2490
|
+
|
|
2491
|
+
[vertical]
|
|
2492
|
+
Examples:::
|
|
2493
|
+
+
|
|
2494
|
+
====
|
|
2495
|
+
.Input
|
|
2496
|
+
[source,liquid]
|
|
2497
|
+
----
|
|
2498
|
+
{{ -17 | abs }}
|
|
2499
|
+
----
|
|
2500
|
+
|
|
2501
|
+
.Output
|
|
2502
|
+
[source,liquid]
|
|
2503
|
+
----
|
|
2504
|
+
17
|
|
2505
|
+
----
|
|
2506
|
+
====
|
|
2507
|
+
+
|
|
2508
|
+
====
|
|
2509
|
+
.Input
|
|
2510
|
+
[source,liquid]
|
|
2511
|
+
----
|
|
2512
|
+
{{ "-19.86" | abs }}
|
|
2513
|
+
----
|
|
2514
|
+
|
|
2515
|
+
.Output
|
|
2516
|
+
[source,liquid]
|
|
2517
|
+
----
|
|
2518
|
+
19.86
|
|
2519
|
+
----
|
|
2520
|
+
====
|
|
2521
|
+
--
|
|
2522
|
+
[[filter__at_least,At Least]]
|
|
2523
|
+
At Least (`at_least`)::
|
|
2524
|
+
+
|
|
2525
|
+
--
|
|
2526
|
+
Limits a number to a minimum value; returns the input unchanged if it's already at or above the minimum.
|
|
2527
|
+
|
|
2528
|
+
[horizontal]
|
|
2529
|
+
Source::: Shopify
|
|
2530
|
+
|
|
2531
|
+
[vertical]
|
|
2532
|
+
Examples:::
|
|
2533
|
+
+
|
|
2534
|
+
====
|
|
2535
|
+
.Input
|
|
2536
|
+
[source,liquid]
|
|
2537
|
+
----
|
|
2538
|
+
{{ 4 | at_least: 5 }}
|
|
2539
|
+
----
|
|
2540
|
+
|
|
2541
|
+
.Output
|
|
2542
|
+
[source,liquid]
|
|
2543
|
+
----
|
|
2544
|
+
5
|
|
2545
|
+
----
|
|
2546
|
+
====
|
|
2547
|
+
+
|
|
2548
|
+
====
|
|
2549
|
+
.Input
|
|
2550
|
+
[source,liquid]
|
|
2551
|
+
----
|
|
2552
|
+
{{ 4 | at_least: 3 }}
|
|
2553
|
+
----
|
|
2554
|
+
|
|
2555
|
+
.Output
|
|
2556
|
+
[source,liquid]
|
|
2557
|
+
----
|
|
2558
|
+
4
|
|
2559
|
+
----
|
|
2560
|
+
====
|
|
2561
|
+
--
|
|
2562
|
+
[[filter__at_most,At Most]]
|
|
2563
|
+
At Most (`at_most`)::
|
|
2564
|
+
+
|
|
2565
|
+
--
|
|
2566
|
+
Limits a number to a maximum value; returns the input unchanged if it's already at or below the maximum.
|
|
2567
|
+
|
|
2568
|
+
[horizontal]
|
|
2569
|
+
Source::: Shopify
|
|
2570
|
+
|
|
2571
|
+
[vertical]
|
|
2572
|
+
Examples:::
|
|
2573
|
+
+
|
|
2574
|
+
====
|
|
2575
|
+
.Input
|
|
2576
|
+
[source,liquid]
|
|
2577
|
+
----
|
|
2578
|
+
{{ 4 | at_most: 5 }}
|
|
2579
|
+
----
|
|
2580
|
+
|
|
2581
|
+
.Output
|
|
2582
|
+
[source,liquid]
|
|
2583
|
+
----
|
|
2584
|
+
4
|
|
2585
|
+
----
|
|
2586
|
+
====
|
|
2587
|
+
+
|
|
2588
|
+
====
|
|
2589
|
+
.Input
|
|
2590
|
+
[source,liquid]
|
|
2591
|
+
----
|
|
2592
|
+
{{ 4 | at_most: 3 }}
|
|
2593
|
+
----
|
|
2594
|
+
|
|
2595
|
+
.Output
|
|
2596
|
+
[source,liquid]
|
|
2597
|
+
----
|
|
2598
|
+
3
|
|
2599
|
+
----
|
|
2600
|
+
====
|
|
2601
|
+
--
|
|
2602
|
+
[[filter__sum,Sum]]
|
|
2603
|
+
Sum (`sum`)::
|
|
2604
|
+
+
|
|
2605
|
+
--
|
|
2606
|
+
Sums a numeric array, or an array of Hashes at the given property.
|
|
2607
|
+
|
|
2608
|
+
(This filter duplicates Shopify's `sum` filter.)
|
|
2609
|
+
|
|
2610
|
+
|
|
2611
|
+
[horizontal]
|
|
2612
|
+
Source::: AsciiSourcerer
|
|
2613
|
+
|
|
2614
|
+
[vertical]
|
|
2615
|
+
Examples:::
|
|
2616
|
+
+
|
|
2617
|
+
====
|
|
2618
|
+
.Input
|
|
2619
|
+
[source,liquid]
|
|
2620
|
+
----
|
|
2621
|
+
{{ data.members | sum: "grad_year" }}
|
|
2622
|
+
----
|
|
2623
|
+
|
|
2624
|
+
.Output
|
|
2625
|
+
[source,liquid]
|
|
2626
|
+
----
|
|
2627
|
+
6040
|
|
2628
|
+
----
|
|
2629
|
+
====
|
|
2630
|
+
--
|
|
2631
|
+
[[filter__ceil,Ceiling]]
|
|
2632
|
+
Ceiling (`ceil`)::
|
|
2633
|
+
+
|
|
2634
|
+
--
|
|
2635
|
+
Rounds a number up to the nearest whole number. Liquid tries to convert the input to a number before applying the filter.
|
|
2636
|
+
|
|
2637
|
+
[horizontal]
|
|
2638
|
+
Source::: Shopify
|
|
2639
|
+
|
|
2640
|
+
[vertical]
|
|
2641
|
+
Examples:::
|
|
2642
|
+
+
|
|
2643
|
+
====
|
|
2644
|
+
.Input
|
|
2645
|
+
[source,liquid]
|
|
2646
|
+
----
|
|
2647
|
+
{{ 1.2 | ceil }}
|
|
2648
|
+
----
|
|
2649
|
+
|
|
2650
|
+
.Output
|
|
2651
|
+
[source,liquid]
|
|
2652
|
+
----
|
|
2653
|
+
2
|
|
2654
|
+
----
|
|
2655
|
+
====
|
|
2656
|
+
--
|
|
2657
|
+
[[filter__divided_by,Divided By]]
|
|
2658
|
+
Divided By (`divided_by`)::
|
|
2659
|
+
+
|
|
2660
|
+
--
|
|
2661
|
+
Divides a number by another number. The result's type matches the
|
|
2662
|
+
divisor's: dividing by an integer floors to an integer, dividing by a
|
|
2663
|
+
float returns a float.
|
|
2664
|
+
|
|
2665
|
+
|
|
2666
|
+
[horizontal]
|
|
2667
|
+
Source::: Shopify
|
|
2668
|
+
|
|
2669
|
+
[vertical]
|
|
2670
|
+
Examples:::
|
|
2671
|
+
+
|
|
2672
|
+
====
|
|
2673
|
+
.Input
|
|
2674
|
+
[source,liquid]
|
|
2675
|
+
----
|
|
2676
|
+
{{ 16 | divided_by: 4 }}
|
|
2677
|
+
----
|
|
2678
|
+
|
|
2679
|
+
.Output
|
|
2680
|
+
[source,liquid]
|
|
2681
|
+
----
|
|
2682
|
+
4
|
|
2683
|
+
----
|
|
2684
|
+
====
|
|
2685
|
+
+
|
|
2686
|
+
====
|
|
2687
|
+
.Input
|
|
2688
|
+
[source,liquid]
|
|
2689
|
+
----
|
|
2690
|
+
{{ 20 | divided_by: 7 }}
|
|
2691
|
+
----
|
|
2692
|
+
|
|
2693
|
+
.Output
|
|
2694
|
+
[source,liquid]
|
|
2695
|
+
----
|
|
2696
|
+
2
|
|
2697
|
+
----
|
|
2698
|
+
====
|
|
2699
|
+
+
|
|
2700
|
+
====
|
|
2701
|
+
.Input
|
|
2702
|
+
[source,liquid]
|
|
2703
|
+
----
|
|
2704
|
+
{{ 20 | divided_by: 7.0 }}
|
|
2705
|
+
----
|
|
2706
|
+
|
|
2707
|
+
.Output
|
|
2708
|
+
[source,liquid]
|
|
2709
|
+
----
|
|
2710
|
+
2.857142857142857
|
|
2711
|
+
----
|
|
2712
|
+
====
|
|
2713
|
+
--
|
|
2714
|
+
[[filter__floor,Floor]]
|
|
2715
|
+
Floor (`floor`)::
|
|
2716
|
+
+
|
|
2717
|
+
--
|
|
2718
|
+
Rounds a number down to the nearest whole number. Liquid tries to convert the input to a number before applying the filter.
|
|
2719
|
+
|
|
2720
|
+
[horizontal]
|
|
2721
|
+
Source::: Shopify
|
|
2722
|
+
|
|
2723
|
+
[vertical]
|
|
2724
|
+
Examples:::
|
|
2725
|
+
+
|
|
2726
|
+
====
|
|
2727
|
+
.Input
|
|
2728
|
+
[source,liquid]
|
|
2729
|
+
----
|
|
2730
|
+
{{ 1.2 | floor }}
|
|
2731
|
+
----
|
|
2732
|
+
|
|
2733
|
+
.Output
|
|
2734
|
+
[source,liquid]
|
|
2735
|
+
----
|
|
2736
|
+
1
|
|
2737
|
+
----
|
|
2738
|
+
====
|
|
2739
|
+
--
|
|
2740
|
+
[[filter__minus,Minus (subtract)]]
|
|
2741
|
+
Minus (subtract) (`minus`)::
|
|
2742
|
+
+
|
|
2743
|
+
--
|
|
2744
|
+
Subtracts a number from another number.
|
|
2745
|
+
|
|
2746
|
+
[horizontal]
|
|
2747
|
+
Source::: Shopify
|
|
2748
|
+
|
|
2749
|
+
[vertical]
|
|
2750
|
+
Examples:::
|
|
2751
|
+
+
|
|
2752
|
+
====
|
|
2753
|
+
.Input
|
|
2754
|
+
[source,liquid]
|
|
2755
|
+
----
|
|
2756
|
+
{{ 4 | minus: 2 }}
|
|
2757
|
+
----
|
|
2758
|
+
|
|
2759
|
+
.Output
|
|
2760
|
+
[source,liquid]
|
|
2761
|
+
----
|
|
2762
|
+
2
|
|
2763
|
+
----
|
|
2764
|
+
====
|
|
2765
|
+
+
|
|
2766
|
+
====
|
|
2767
|
+
.Input
|
|
2768
|
+
[source,liquid]
|
|
2769
|
+
----
|
|
2770
|
+
{{ 16 | minus: 4 }}
|
|
2771
|
+
----
|
|
2772
|
+
|
|
2773
|
+
.Output
|
|
2774
|
+
[source,liquid]
|
|
2775
|
+
----
|
|
2776
|
+
12
|
|
2777
|
+
----
|
|
2778
|
+
====
|
|
2779
|
+
--
|
|
2780
|
+
[[filter__modulo,Modulo]]
|
|
2781
|
+
Modulo (`modulo`)::
|
|
2782
|
+
+
|
|
2783
|
+
--
|
|
2784
|
+
Returns the remainder of a division operation.
|
|
2785
|
+
|
|
2786
|
+
[horizontal]
|
|
2787
|
+
Source::: Shopify
|
|
2788
|
+
|
|
2789
|
+
[vertical]
|
|
2790
|
+
Examples:::
|
|
2791
|
+
+
|
|
2792
|
+
====
|
|
2793
|
+
.Input
|
|
2794
|
+
[source,liquid]
|
|
2795
|
+
----
|
|
2796
|
+
{{ 3 | modulo: 2 }}
|
|
2797
|
+
----
|
|
2798
|
+
|
|
2799
|
+
.Output
|
|
2800
|
+
[source,liquid]
|
|
2801
|
+
----
|
|
2802
|
+
1
|
|
2803
|
+
----
|
|
2804
|
+
====
|
|
2805
|
+
+
|
|
2806
|
+
====
|
|
2807
|
+
.Input
|
|
2808
|
+
[source,liquid]
|
|
2809
|
+
----
|
|
2810
|
+
{{ 24 | modulo: 7 }}
|
|
2811
|
+
----
|
|
2812
|
+
|
|
2813
|
+
.Output
|
|
2814
|
+
[source,liquid]
|
|
2815
|
+
----
|
|
2816
|
+
3
|
|
2817
|
+
----
|
|
2818
|
+
====
|
|
2819
|
+
--
|
|
2820
|
+
[[filter__plus,Plus (add)]]
|
|
2821
|
+
Plus (add) (`plus`)::
|
|
2822
|
+
+
|
|
2823
|
+
--
|
|
2824
|
+
Adds a number to another number.
|
|
2825
|
+
|
|
2826
|
+
[horizontal]
|
|
2827
|
+
Source::: Shopify
|
|
2828
|
+
|
|
2829
|
+
[vertical]
|
|
2830
|
+
Examples:::
|
|
2831
|
+
+
|
|
2832
|
+
====
|
|
2833
|
+
.Input
|
|
2834
|
+
[source,liquid]
|
|
2835
|
+
----
|
|
2836
|
+
{{ 4 | plus: 2 }}
|
|
2837
|
+
----
|
|
2838
|
+
|
|
2839
|
+
.Output
|
|
2840
|
+
[source,liquid]
|
|
2841
|
+
----
|
|
2842
|
+
6
|
|
2843
|
+
----
|
|
2844
|
+
====
|
|
2845
|
+
--
|
|
2846
|
+
[[filter__round,Round]]
|
|
2847
|
+
Round (`round`)::
|
|
2848
|
+
+
|
|
2849
|
+
--
|
|
2850
|
+
Rounds a number to the nearest integer, or to a given number of decimal places if an argument is passed.
|
|
2851
|
+
|
|
2852
|
+
[horizontal]
|
|
2853
|
+
Source::: Shopify
|
|
2854
|
+
|
|
2855
|
+
[vertical]
|
|
2856
|
+
Examples:::
|
|
2857
|
+
+
|
|
2858
|
+
====
|
|
2859
|
+
.Input
|
|
2860
|
+
[source,liquid]
|
|
2861
|
+
----
|
|
2862
|
+
{{ 1.2 | round }}
|
|
2863
|
+
----
|
|
2864
|
+
|
|
2865
|
+
.Output
|
|
2866
|
+
[source,liquid]
|
|
2867
|
+
----
|
|
2868
|
+
1
|
|
2869
|
+
----
|
|
2870
|
+
====
|
|
2871
|
+
+
|
|
2872
|
+
====
|
|
2873
|
+
.Input
|
|
2874
|
+
[source,liquid]
|
|
2875
|
+
----
|
|
2876
|
+
{{ 2.7 | round }}
|
|
2877
|
+
----
|
|
2878
|
+
|
|
2879
|
+
.Output
|
|
2880
|
+
[source,liquid]
|
|
2881
|
+
----
|
|
2882
|
+
3
|
|
2883
|
+
----
|
|
2884
|
+
====
|
|
2885
|
+
+
|
|
2886
|
+
====
|
|
2887
|
+
.Input
|
|
2888
|
+
[source,liquid]
|
|
2889
|
+
----
|
|
2890
|
+
{{ 183.357 | round: 2 }}
|
|
2891
|
+
----
|
|
2892
|
+
|
|
2893
|
+
.Output
|
|
2894
|
+
[source,liquid]
|
|
2895
|
+
----
|
|
2896
|
+
183.36
|
|
2897
|
+
----
|
|
2898
|
+
====
|
|
2899
|
+
--
|
|
2900
|
+
[[filter__times,Times (multiply)]]
|
|
2901
|
+
Times (multiply) (`times`)::
|
|
2902
|
+
+
|
|
2903
|
+
--
|
|
2904
|
+
Multiplies a number by another number.
|
|
2905
|
+
|
|
2906
|
+
[horizontal]
|
|
2907
|
+
Source::: Shopify
|
|
2908
|
+
|
|
2909
|
+
[vertical]
|
|
2910
|
+
Examples:::
|
|
2911
|
+
+
|
|
2912
|
+
====
|
|
2913
|
+
.Input
|
|
2914
|
+
[source,liquid]
|
|
2915
|
+
----
|
|
2916
|
+
{{ 3 | times: 2 }}
|
|
2917
|
+
----
|
|
2918
|
+
|
|
2919
|
+
.Output
|
|
2920
|
+
[source,liquid]
|
|
2921
|
+
----
|
|
2922
|
+
6
|
|
2923
|
+
----
|
|
2924
|
+
====
|
|
2925
|
+
--
|
|
2926
|
+
// end::math[]
|
|
2927
|
+
|
|
2928
|
+
:example-capition!:
|
|
2929
|
+
|
|
2930
|
+
[[string-management]]
|
|
2931
|
+
== String management Filters
|
|
2932
|
+
|
|
2933
|
+
// tag::string-management[]
|
|
2934
|
+
[[filter__append,Append]]
|
|
2935
|
+
Append (`append`)::
|
|
2936
|
+
+
|
|
2937
|
+
--
|
|
2938
|
+
Adds the specified string to the end of another string.
|
|
2939
|
+
|
|
2940
|
+
[horizontal]
|
|
2941
|
+
Source::: Shopify
|
|
2942
|
+
|
|
2943
|
+
[vertical]
|
|
2944
|
+
Examples:::
|
|
2945
|
+
+
|
|
2946
|
+
====
|
|
2947
|
+
.Input
|
|
2948
|
+
[source,liquid]
|
|
2949
|
+
----
|
|
2950
|
+
{{ "/my/fancy/url" | append: ".html" }}
|
|
2951
|
+
----
|
|
2952
|
+
|
|
2953
|
+
.Output
|
|
2954
|
+
[source,liquid]
|
|
2955
|
+
----
|
|
2956
|
+
/my/fancy/url.html
|
|
2957
|
+
----
|
|
2958
|
+
====
|
|
2959
|
+
--
|
|
2960
|
+
[[filter__lstrip,Left Strip]]
|
|
2961
|
+
Left Strip (`lstrip`)::
|
|
2962
|
+
+
|
|
2963
|
+
--
|
|
2964
|
+
Removes whitespace (tabs, spaces, newlines) from the left side of a
|
|
2965
|
+
string. Does not affect spaces between words.
|
|
2966
|
+
|
|
2967
|
+
|
|
2968
|
+
[horizontal]
|
|
2969
|
+
Source::: Shopify
|
|
2970
|
+
|
|
2971
|
+
[vertical]
|
|
2972
|
+
Examples:::
|
|
2973
|
+
+
|
|
2974
|
+
====
|
|
2975
|
+
.Input
|
|
2976
|
+
[source,liquid]
|
|
2977
|
+
----
|
|
2978
|
+
{{ " So much room " | lstrip }}!
|
|
2979
|
+
----
|
|
2980
|
+
|
|
2981
|
+
.Output
|
|
2982
|
+
[source,liquid]
|
|
2983
|
+
----
|
|
2984
|
+
So much room !
|
|
2985
|
+
----
|
|
2986
|
+
====
|
|
2987
|
+
--
|
|
2988
|
+
[[filter__prepend,Prepend]]
|
|
2989
|
+
Prepend (`prepend`)::
|
|
2990
|
+
+
|
|
2991
|
+
--
|
|
2992
|
+
Adds the specified string to the beginning of another string.
|
|
2993
|
+
|
|
2994
|
+
[horizontal]
|
|
2995
|
+
Source::: Shopify
|
|
2996
|
+
|
|
2997
|
+
[vertical]
|
|
2998
|
+
Examples:::
|
|
2999
|
+
+
|
|
3000
|
+
====
|
|
3001
|
+
.Input
|
|
3002
|
+
[source,liquid]
|
|
3003
|
+
----
|
|
3004
|
+
{{ "apples, oranges, and bananas" | prepend: "Some fruit: " }}
|
|
3005
|
+
----
|
|
3006
|
+
|
|
3007
|
+
.Output
|
|
3008
|
+
[source,liquid]
|
|
3009
|
+
----
|
|
3010
|
+
Some fruit: apples, oranges, and bananas
|
|
3011
|
+
----
|
|
3012
|
+
====
|
|
3013
|
+
--
|
|
3014
|
+
[[filter__truncate,Truncate]]
|
|
3015
|
+
Truncate (`truncate`)::
|
|
3016
|
+
+
|
|
3017
|
+
--
|
|
3018
|
+
Shortens a string to the given number of characters. If shortened, an
|
|
3019
|
+
ellipsis (`...`) is appended and counts against the total; pass a
|
|
3020
|
+
second argument to use a different (or no) ellipsis.
|
|
3021
|
+
|
|
3022
|
+
|
|
3023
|
+
[horizontal]
|
|
3024
|
+
Source::: Shopify
|
|
3025
|
+
|
|
3026
|
+
[vertical]
|
|
3027
|
+
Examples:::
|
|
3028
|
+
+
|
|
3029
|
+
====
|
|
3030
|
+
.Input
|
|
3031
|
+
[source,liquid]
|
|
3032
|
+
----
|
|
3033
|
+
{{ "Ground control to Major Tom." | truncate: 20 }}
|
|
3034
|
+
----
|
|
3035
|
+
|
|
3036
|
+
.Output
|
|
3037
|
+
[source,liquid]
|
|
3038
|
+
----
|
|
3039
|
+
Ground control to...
|
|
3040
|
+
----
|
|
3041
|
+
====
|
|
3042
|
+
+
|
|
3043
|
+
====
|
|
3044
|
+
.Input
|
|
3045
|
+
[source,liquid]
|
|
3046
|
+
----
|
|
3047
|
+
{{ "Ground control to Major Tom." | truncate: 25, ", and so on" }}
|
|
3048
|
+
----
|
|
3049
|
+
|
|
3050
|
+
.Output
|
|
3051
|
+
[source,liquid]
|
|
3052
|
+
----
|
|
3053
|
+
Ground control, and so on
|
|
3054
|
+
----
|
|
3055
|
+
====
|
|
3056
|
+
--
|
|
3057
|
+
[[filter__replace_regex,Regular Expression Replace]]
|
|
3058
|
+
Regular Expression Replace (`replace_regex`)::
|
|
3059
|
+
+
|
|
3060
|
+
--
|
|
3061
|
+
Use regular expressions to match and replace text patterns.
|
|
3062
|
+
|
|
3063
|
+
[horizontal]
|
|
3064
|
+
Source::: AsciiSourcerer
|
|
3065
|
+
|
|
3066
|
+
[vertical]
|
|
3067
|
+
Examples:::
|
|
3068
|
+
+
|
|
3069
|
+
====
|
|
3070
|
+
.Input
|
|
3071
|
+
[source,liquid]
|
|
3072
|
+
----
|
|
3073
|
+
{{ "hello world" | replace_regex: "world", "there" }}
|
|
3074
|
+
----
|
|
3075
|
+
|
|
3076
|
+
.Output
|
|
3077
|
+
[source,liquid]
|
|
3078
|
+
----
|
|
3079
|
+
hello there
|
|
3080
|
+
----
|
|
3081
|
+
====
|
|
3082
|
+
+
|
|
3083
|
+
====
|
|
3084
|
+
.Input
|
|
3085
|
+
[source,liquid]
|
|
3086
|
+
----
|
|
3087
|
+
{{ "one,two,three" | replace_regex: ",", "-" }}
|
|
3088
|
+
----
|
|
3089
|
+
|
|
3090
|
+
.Output
|
|
3091
|
+
[source,liquid]
|
|
3092
|
+
----
|
|
3093
|
+
one-two-three
|
|
3094
|
+
----
|
|
3095
|
+
====
|
|
3096
|
+
--
|
|
3097
|
+
// end::string-management[]
|
|
3098
|
+
|
|
3099
|
+
:example-capition!:
|
|
3100
|
+
|
|
3101
|
+
[[variable]]
|
|
3102
|
+
== Variable Filters
|
|
3103
|
+
|
|
3104
|
+
// tag::variable[]
|
|
3105
|
+
[[filter__default,Default]]
|
|
3106
|
+
Default (`default`)::
|
|
3107
|
+
+
|
|
3108
|
+
--
|
|
3109
|
+
Sets a fallback value for a variable that is `nil`, `false`, or empty.
|
|
3110
|
+
Has no effect if the input already has a value.
|
|
3111
|
+
|
|
3112
|
+
|
|
3113
|
+
[horizontal]
|
|
3114
|
+
Source::: Shopify
|
|
3115
|
+
|
|
3116
|
+
[vertical]
|
|
3117
|
+
Examples:::
|
|
3118
|
+
+
|
|
3119
|
+
====
|
|
3120
|
+
.Input
|
|
3121
|
+
[source,liquid]
|
|
3122
|
+
----
|
|
3123
|
+
{{ nonexistent_var | default: "fallback" }}
|
|
3124
|
+
----
|
|
3125
|
+
|
|
3126
|
+
.Output
|
|
3127
|
+
[source,liquid]
|
|
3128
|
+
----
|
|
3129
|
+
fallback
|
|
3130
|
+
----
|
|
3131
|
+
====
|
|
3132
|
+
--
|
|
3133
|
+
// end::variable[]
|
|
3134
|
+
|
|
3135
|
+
:example-capition!:
|
|
3136
|
+
|
|
3137
|
+
[[string-recode]]
|
|
3138
|
+
== String recode Filters
|
|
3139
|
+
|
|
3140
|
+
// tag::string-recode[]
|
|
3141
|
+
[[filter__url_decode,URL Decode]]
|
|
3142
|
+
URL Decode (`url_decode`)::
|
|
3143
|
+
+
|
|
3144
|
+
--
|
|
3145
|
+
Decodes a string that has been encoded as a URL, or by `url_encode`.
|
|
3146
|
+
|
|
3147
|
+
[horizontal]
|
|
3148
|
+
Source::: Shopify
|
|
3149
|
+
|
|
3150
|
+
[vertical]
|
|
3151
|
+
Examples:::
|
|
3152
|
+
+
|
|
3153
|
+
====
|
|
3154
|
+
.Input
|
|
3155
|
+
[source,liquid]
|
|
3156
|
+
----
|
|
3157
|
+
{{ "%27Stop%21%27+said+Fred" | url_decode }}
|
|
3158
|
+
----
|
|
3159
|
+
|
|
3160
|
+
.Output
|
|
3161
|
+
[source,liquid]
|
|
3162
|
+
----
|
|
3163
|
+
'Stop!' said Fred
|
|
3164
|
+
----
|
|
3165
|
+
====
|
|
3166
|
+
--
|
|
3167
|
+
[[filter__url_encode,URL Encode]]
|
|
3168
|
+
URL Encode (`url_encode`)::
|
|
3169
|
+
+
|
|
3170
|
+
--
|
|
3171
|
+
Converts any URL-unsafe characters in a string into percent-encoded
|
|
3172
|
+
characters. A space becomes a `+` rather than a percent-encoded
|
|
3173
|
+
character.
|
|
3174
|
+
|
|
3175
|
+
|
|
3176
|
+
[horizontal]
|
|
3177
|
+
Source::: Shopify
|
|
3178
|
+
|
|
3179
|
+
[vertical]
|
|
3180
|
+
Examples:::
|
|
3181
|
+
+
|
|
3182
|
+
====
|
|
3183
|
+
.Input
|
|
3184
|
+
[source,liquid]
|
|
3185
|
+
----
|
|
3186
|
+
{{ "john@liquid.com" | url_encode }}
|
|
3187
|
+
----
|
|
3188
|
+
|
|
3189
|
+
.Output
|
|
3190
|
+
[source,liquid]
|
|
3191
|
+
----
|
|
3192
|
+
john%40liquid.com
|
|
3193
|
+
----
|
|
3194
|
+
====
|
|
3195
|
+
+
|
|
3196
|
+
====
|
|
3197
|
+
.Input
|
|
3198
|
+
[source,liquid]
|
|
3199
|
+
----
|
|
3200
|
+
{{ "Tetsuro Takara" | url_encode }}
|
|
3201
|
+
----
|
|
3202
|
+
|
|
3203
|
+
.Output
|
|
3204
|
+
[source,liquid]
|
|
3205
|
+
----
|
|
3206
|
+
Tetsuro+Takara
|
|
3207
|
+
----
|
|
3208
|
+
====
|
|
3209
|
+
--
|
|
3210
|
+
// end::string-recode[]
|
|
3211
|
+
|
|
3212
|
+
:example-capition!:
|
|
3213
|
+
|
|
3214
|
+
[[data-type]]
|
|
3215
|
+
== Data type Filters
|
|
3216
|
+
|
|
3217
|
+
// tag::data-type[]
|
|
3218
|
+
[[filter__sgyml_type,SGYML Type]]
|
|
3219
|
+
SGYML Type (`sgyml_type`)::
|
|
3220
|
+
+
|
|
3221
|
+
--
|
|
3222
|
+
|
|
3223
|
+
|
|
3224
|
+
[horizontal]
|
|
3225
|
+
Source::: schemagraphy
|
|
3226
|
+
--
|
|
3227
|
+
// end::data-type[]
|