-
-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: pop/shift/unshift filters from Jekyll
- Loading branch information
Showing
17 changed files
with
240 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
title: pop | ||
--- | ||
|
||
{% since %}v10.11.0{% endsince %} | ||
|
||
Pop an element from the array. It's NON-DESTRUCTIVE, i.e. it does not mutate the array, but rather make a copy and mutate that. | ||
|
||
Input | ||
```liquid | ||
{% assign fruits = "apples, oranges, peaches" | split: ", " %} | ||
{% assign everything = fruits | pop %} | ||
{% for item in everything %} | ||
- {{ item }} | ||
{% endfor %} | ||
``` | ||
|
||
Output | ||
```text | ||
- apples | ||
- oranges | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
title: shift | ||
--- | ||
|
||
{% since %}v10.11.0{% endsince %} | ||
|
||
Shift an element from the array. It's NON-DESTRUCTIVE, i.e. it does not mutate the array, but rather make a copy and mutate that. | ||
|
||
Input | ||
```liquid | ||
{% assign fruits = "apples, oranges, peaches" | split: ", " %} | ||
{% assign everything = fruits | shift %} | ||
{% for item in everything %} | ||
- {{ item }} | ||
{% endfor %} | ||
``` | ||
|
||
Output | ||
```text | ||
- oranges | ||
- peaches | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
title: unshift | ||
--- | ||
|
||
{% since %}v10.11.0{% endsince %} | ||
|
||
Unshift an element to the front of the array. It's NON-DESTRUCTIVE, i.e. it does not mutate the array, but rather make a copy and mutate that. | ||
|
||
Input | ||
```liquid | ||
{% assign fruits = "oranges, peaches" | split: ", " %} | ||
{% assign everything = fruits | unshift: "apples" %} | ||
{% for item in everything %} | ||
- {{ item }} | ||
{% endfor %} | ||
``` | ||
|
||
Output | ||
```text | ||
- apples | ||
- oranges | ||
- peaches | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
title: pop | ||
--- | ||
|
||
{% since %}v10.11.0{% endsince %} | ||
|
||
从数组末尾弹出一个元素。注意该操作不会改变原数组,而是在一份拷贝上操作。 | ||
|
||
输入 | ||
```liquid | ||
{% assign fruits = "apples, oranges, peaches" | split: ", " %} | ||
{% assign everything = fruits | pop %} | ||
{% for item in everything %} | ||
- {{ item }} | ||
{% endfor %} | ||
``` | ||
|
||
输出 | ||
```text | ||
- apples | ||
- oranges | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
title: shift | ||
--- | ||
|
||
{% since %}v10.11.0{% endsince %} | ||
|
||
从数组头部弹出一个元素。注意该操作不会改变原数组,而是在一份拷贝上操作。 | ||
|
||
输入 | ||
```liquid | ||
{% assign fruits = "apples, oranges, peaches" | split: ", " %} | ||
{% assign everything = fruits | shift %} | ||
{% for item in everything %} | ||
- {{ item }} | ||
{% endfor %} | ||
``` | ||
|
||
输出 | ||
```text | ||
- oranges | ||
- peaches | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
title: unshift | ||
--- | ||
|
||
{% since %}v10.11.0{% endsince %} | ||
|
||
往数组头部添加一个元素。注意该操作不会改变原数组,而是在一份拷贝上操作。 | ||
|
||
输入 | ||
```liquid | ||
{% assign fruits = "oranges, peaches" | split: ", " %} | ||
{% assign everything = fruits | unshift: "apples" %} | ||
{% for item in everything %} | ||
- {{ item }} | ||
{% endfor %} | ||
``` | ||
|
||
输出 | ||
```text | ||
- apples | ||
- oranges | ||
- peaches | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.