-
-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
46 changed files
with
1,067 additions
and
155 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,25 @@ | ||
--- | ||
title: find | ||
--- | ||
|
||
{% since %}v10.11.0{% endsince %} | ||
|
||
Return the first object in an array for which the queried attribute has the given value or return `nil` if no item in the array satisfies the given criteria. For the following `members` array: | ||
|
||
```javascript | ||
const members = [ | ||
{ graduation_year: 2013, name: 'Jay' }, | ||
{ graduation_year: 2014, name: 'John' }, | ||
{ graduation_year: 2014, name: 'Jack' } | ||
] | ||
``` | ||
|
||
Input | ||
```liquid | ||
{{ members | find: "graduation_year", 2014 | json }} | ||
``` | ||
|
||
Output | ||
```text | ||
{"graduation_year":2014,"name":"John"} | ||
``` |
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: find_exp | ||
--- | ||
|
||
{% since %}v10.11.0{% endsince %} | ||
|
||
Return the first object in an array for which the given expression evaluates to true or return `nil` if no item in the array satisfies the evaluated expression. | ||
|
||
```javascript | ||
const members = [ | ||
{ graduation_year: 2013, name: 'Jay' }, | ||
{ graduation_year: 2014, name: 'John' }, | ||
{ graduation_year: 2014, name: 'Jack' } | ||
] | ||
``` | ||
|
||
Input | ||
```liquid | ||
{{ members | find_exp: "item", "item.graduation_year == 2014" | json }} | ||
``` | ||
|
||
Output | ||
```text | ||
{"graduation_year":2014,"name":"John"} | ||
``` |
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,48 @@ | ||
--- | ||
title: group_by | ||
--- | ||
|
||
{% since %}v10.11.0{% endsince %} | ||
|
||
Group an array's items by a given property. For `members` array: | ||
|
||
```javascript | ||
const members = [ | ||
{ graduation_year: 2003, name: 'Jay' }, | ||
{ graduation_year: 2003, name: 'John' }, | ||
{ graduation_year: 2004, name: 'Jack' } | ||
] | ||
``` | ||
|
||
Input | ||
```liquid | ||
{{ members | group_by: "graduation_year" | json: 2 }} | ||
``` | ||
|
||
Output | ||
```text | ||
[ | ||
{ | ||
"name": 2003, | ||
"items": [ | ||
{ | ||
"graduation_year": 2003, | ||
"name": "Jay" | ||
}, | ||
{ | ||
"graduation_year": 2003, | ||
"name": "John" | ||
} | ||
] | ||
}, | ||
{ | ||
"name": 2004, | ||
"items": [ | ||
{ | ||
"graduation_year": 2004, | ||
"name": "Jack" | ||
} | ||
] | ||
} | ||
] | ||
``` |
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,48 @@ | ||
--- | ||
title: group_by_exp | ||
--- | ||
|
||
{% since %}v10.11.0{% endsince %} | ||
|
||
Group an array's items using a Liquid expression. For `members` array below: | ||
|
||
```javascript | ||
const members = [ | ||
{ graduation_year: 2013, name: 'Jay' }, | ||
{ graduation_year: 2014, name: 'John' }, | ||
{ graduation_year: 2009, name: 'Jack' } | ||
] | ||
``` | ||
|
||
Input | ||
```liquid | ||
{{ members | group_by_exp: "item", "item.graduation_year | truncate: 3, ''" | json: 2 }} | ||
``` | ||
|
||
Output | ||
```text | ||
[ | ||
{ | ||
"name": "201", | ||
"items": [ | ||
{ | ||
"graduation_year": 2013, | ||
"name": "Jay" | ||
}, | ||
{ | ||
"graduation_year": 2014, | ||
"name": "John" | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "200", | ||
"items": [ | ||
{ | ||
"graduation_year": 2009, | ||
"name": "Jack" | ||
} | ||
] | ||
} | ||
] | ||
``` |
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,25 @@ | ||
--- | ||
title: push | ||
--- | ||
|
||
{% since %}v10.8.0{% endsince %} | ||
|
||
Push an element into 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" | split: ", " %} | ||
{% assign everything = fruits | push: "peaches" %} | ||
{% 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
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
Oops, something went wrong.