/
jekyll_filters.yml
347 lines (289 loc) · 9.92 KB
/
jekyll_filters.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
#
# ---------------------------------------------------------------------------------------
# List of Liquid Filters provided by Jekyll Core that will be utilized for their
# documentation.
#
# To document a new filter, create a new "list-item" below with the following keys:
# name: : [REQUIRED] A string label that identifies the filter
# description: : [REQUIRED] A short description of what to expect from the filter
# version_badge: : [OPTIONAL] Jekyll version that introduced the filter
# examples: : [REQUIRED] A 'nested list' comprised of inputs and outputs
# input: : [REQUIRED] The filter syntax and usage
# output: : [OPTIONAL] The output from the filter
#
# Tip: Use YAML Block notations to "fold" a long string, or to "break" a long string
# to the following line. Block notations can also be used to avoid having to use
# backslashes to escape quotes.
# ---------------------------------------------------------------------------------------
#
- name: Relative URL
description: >-
Prepend the <code>baseurl</code> value to the input. Useful if
your site is hosted at a subpath rather than the root of the domain.
examples:
- input: '{{ "/assets/style.css" | relative_url }}'
output: '/my-baseurl/assets/style.css'
#
- name: Absolute URL
description: Prepend the <code>url</code> and <code>baseurl</code> value to the input.
examples:
- input: '{{ "/assets/style.css" | absolute_url }}'
output: 'http://example.com/my-baseurl/assets/style.css'
#
- name: Date to XML Schema
description: Convert a Date into XML Schema (ISO 8601) format.
examples:
- input: '{{ site.time | date_to_xmlschema }}'
output: '2008-11-07T13:07:54-08:00'
#
- name: Date to RFC-822 Format
description: Convert a Date into the RFC-822 format used for RSS feeds.
examples:
- input: '{{ site.time | date_to_rfc822 }}'
output: 'Mon, 07 Nov 2008 13:07:54 -0800'
#
- name: Date to String
description: Convert a date to short format.
examples:
- input: '{{ site.time | date_to_string }}'
output: '07 Nov 2008'
#
- name: Date to String in ordinal US style
description: 'Format a date to ordinal, US, short format.'
version_badge: 3.8.0
examples:
- input: '{{ site.time | date_to_string: "ordinal", "US" }}'
output: 'Nov 7th, 2008'
#
- name: Date to Long String
description: Format a date to long format.
examples:
- input: '{{ site.time | date_to_long_string }}'
output: '07 November 2008'
#
- name: Date to Long String in ordinal UK style
description: 'Format a date to ordinal, UK, long format.'
version_badge: 3.8.0
examples:
- input: '{{ site.time | date_to_long_string: "ordinal" }}'
output: '7th November 2008'
#
- name: Where
description: Select all the objects in an array where the key has the given value.
examples:
- input: '{{ site.members | where:"graduation_year","2014" }}'
output:
#
- name: Where Expression
description: Select all the objects in an array where the expression is true.
version_badge: 3.2.0
examples:
- input: |-
{{ site.members | where_exp:"item",
"item.graduation_year == 2014" }}
output:
- input: |-
{{ site.members | where_exp:"item",
"item.graduation_year < 2014" }}
output:
- input: |-
{{ site.members | where_exp:"item",
"item.projects contains 'foo'" }}
output:
#
- name: Find
description: >-
Return <strong>the first object</strong> in an array for which the queried
attribute has the given value or return <code>nil</code> if no item in
the array satisfies the given criteria.
version_badge: 4.1.0
examples:
- input: '{{ site.members | find: "graduation_year", "2014" }}'
output:
#
- name: Find Expression
description: >-
Return <strong>the first object</strong> in an array for which the given
expression evaluates to true or return <code>nil</code> if no item in
the array satisfies the evaluated expression.
version_badge: 4.1.0
examples:
- input: |-
{{ site.members | find_exp:"item",
"item.graduation_year == 2014" }}
output:
- input: |-
{{ site.members | find_exp:"item",
"item.graduation_year < 2014" }}
output:
- input: |-
{{ site.members | find_exp:"item",
"item.projects contains 'foo'" }}
output:
#
- name: Group By
description: Group an array's items by a given property.
examples:
- input: '{{ site.members | group_by:"graduation_year" }}'
output: |-
[{"name"=>"2013", "items"=>[...]},
{"name"=>"2014", "items"=>[...]}]
#
- name: Group By Expression
description: Group an array's items using a Liquid expression.
version_badge: 3.4.0
examples:
- input: |-
{{ site.members | group_by_exp: "item",
"item.graduation_year | truncate: 3, ''" }}
output: |-
[{"name"=>"201", "items"=>[...]},
{"name"=>"200", "items"=>[...]}]
#
- name: XML Escape
description: Escape some text for use in XML.
examples:
- input: '{{ page.content | xml_escape }}'
output:
#
- name: CGI Escape
description: >-
CGI escape a string for use in a URL. Replaces any special characters
with appropriate <code>%XX</code> replacements. CGI escape normally
replaces a space with a plus <code>+</code> sign.
examples:
- input: '{{ "foo, bar; baz?" | cgi_escape }}'
output: 'foo%2C+bar%3B+baz%3F'
#
- name: URI Escape
description: >-
Percent encodes any special characters in a URI.
URI escape normally replaces a space with <code>%20</code>.
<a href="https://en.wikipedia.org/wiki/Percent-encoding#Types_of_URI_characters">Reserved characters</a>
will not be escaped.
examples:
- input: '{{ "http://foo.com/?q=foo, \bar?" | uri_escape }}'
output: 'http://foo.com/?q=foo,%20%5Cbar?'
#
- name: Number of Words
description: >-
Count the number of words in some text.<br/>
From <span class="version-badge">v4.1.0</span>, this filter takes an optional
argument to control the handling of Chinese-Japanese-Korean (CJK) characters
in the <code>input</code> string.<br/>
Passing <code>'cjk'</code> as the argument will count every CJK character
detected as one word irrespective of being separated by whitespace.<br/>
Passing <code>'auto'</code> (auto-detect) works similar to <code>'cjk'</code>
but is more performant if the filter is used on a variable string that may
or may not contain CJK chars.
examples:
- input: '{{ "Hello world!" | number_of_words }}'
output: 2
- input: '{{ "你好hello世界world" | number_of_words }}'
output: 1
- input: '{{ "你好hello世界world" | number_of_words: "cjk" }}'
output: 6
- input: '{{ "你好hello世界world" | number_of_words: "auto" }}'
output: 6
#
- name: Array to Sentence
description: >-
Convert an array into a sentence. Useful for listing tags.
Optional argument for connector.
examples:
- input: '{{ page.tags | array_to_sentence_string }}'
output: 'foo, bar, and baz'
- input: '{{ page.tags | array_to_sentence_string: "or" }}'
output: 'foo, bar, or baz'
#
- name: Markdownify
description: Convert a Markdown-formatted string into HTML.
examples:
- input: '{{ page.excerpt | markdownify }}'
output:
#
- name: Smartify
description: 'Convert "quotes" into “smart quotes.”'
examples:
- input: '{{ page.title | smartify }}'
output:
#
- name: Converting Sass/SCSS
description: Convert a Sass- or SCSS-formatted string into CSS.
examples:
- input: '{{ some_sass | sassify }}'
output:
- input: '{{ some_scss | scssify }}'
output:
#
- name: Slugify
description: Convert a string into a lowercase URL "slug". See below for options.
examples:
- input: '{{ "The _config.yml file" | slugify }}'
output: 'the-config-yml-file'
- input: '{{ "The _config.yml file" | slugify: "pretty" }}'
output: 'the-_config.yml-file'
- input: '{{ "The _cönfig.yml file" | slugify: "ascii" }}'
output: 'the-c-nfig-yml-file'
- input: '{{ "The cönfig.yml file" | slugify: "latin" }}'
output: 'the-config-yml-file'
#
- name: Data To JSON
description: Convert Hash or Array to JSON.
examples:
- input: '{{ site.data.projects | jsonify }}'
output:
#
- name: Normalize Whitespace
description: Replace any occurrence of whitespace with a single space.
examples:
- input: '{{ "a \n b" | normalize_whitespace }}'
output:
#
- name: Sort
description: >-
Sort an array. Optional arguments for hashes
1. property name
2. nils order (<em>first</em> or <em>last</em>).
examples:
- input: '{{ page.tags | sort }}'
output:
- input: '{{ site.posts | sort: "author" }}'
output:
- input: '{{ site.pages | sort: "title", "last" }}'
output:
#
- name: Sample
description: 'Pick a random value from an array. Optionally, pick multiple values.'
examples:
- input: '{{ site.pages | sample }}'
output:
- input: '{{ site.pages | sample: 2 }}'
output:
#
- name: To Integer
description: Convert a string or boolean to integer.
examples:
- input: '{{ some_var | to_integer }}'
output:
#
- name: Array Filters
description: >-
Push, pop, shift, and unshift elements from an Array.
These are <strong>NON-DESTRUCTIVE</strong>, i.e. they do not mutate the array,
but rather make a copy and mutate that.
examples:
- input: '{{ page.tags | push: "Spokane" }}'
output: '["Seattle", "Tacoma", "Spokane"]'
- input: '{{ page.tags | pop }}'
output: '["Seattle"]'
- input: '{{ page.tags | shift }}'
output: '["Tacoma"]'
- input: '{{ page.tags | unshift: "Olympia" }}'
output: '["Olympia", "Seattle", "Tacoma"]'
#
- name: Inspect
description: Convert an object into its String representation for debugging.
examples:
- input: '{{ some_var | inspect }}'
output: