mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 04:10:40 -07:00
feat: pop/shift/unshift filters from Jekyll
This commit is contained in:
@@ -51,6 +51,7 @@ filters:
|
||||
modulo: modulo.html
|
||||
newline_to_br: newline_to_br.html
|
||||
plus: plus.html
|
||||
pop: pop.html
|
||||
push: push.html
|
||||
prepend: prepend.html
|
||||
raw: raw.html
|
||||
@@ -63,6 +64,7 @@ filters:
|
||||
reverse: reverse.html
|
||||
round: round.html
|
||||
rstrip: rstrip.html
|
||||
shift: shift.html
|
||||
size: size.html
|
||||
slice: slice.html
|
||||
sort: sort.html
|
||||
@@ -76,6 +78,7 @@ filters:
|
||||
truncate: truncate.html
|
||||
truncatewords: truncatewords.html
|
||||
uniq: uniq.html
|
||||
unshift: unshift.html
|
||||
upcase: upcase.html
|
||||
url_decode: url_decode.html
|
||||
url_encode: url_encode.html
|
||||
|
||||
@@ -12,7 +12,7 @@ Categories | Filters
|
||||
Math | plus, minus, modulo, times, floor, ceil, round, divided_by, abs, at_least, at_most
|
||||
String | append, prepend, capitalize, upcase, downcase, strip, lstrip, rstrip, strip_newlines, split, replace, replace_first, replace_last,remove, remove_first, remove_last, truncate, truncatewords
|
||||
HTML/URI | escape, escape_once, url_encode, url_decode, strip_html, newline_to_br
|
||||
Array | slice, map, sort, sort_natural, uniq, where, first, last, join, reverse, concat, compact, size, push
|
||||
Array | slice, map, sort, sort_natural, uniq, where, first, last, join, reverse, concat, compact, size, push, pop, shift, unshift
|
||||
Date | date
|
||||
Misc | default, json, raw
|
||||
|
||||
|
||||
@@ -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
|
||||
```
|
||||
@@ -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
|
||||
```
|
||||
@@ -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
|
||||
```
|
||||
@@ -12,7 +12,7 @@ LiquidJS 共支持 40+ 个过滤器,可以分为如下几类:
|
||||
数学 | plus, minus, modulo, times, floor, ceil, round, divided_by, abs, at_least, at_most
|
||||
字符串 | append, prepend, capitalize, upcase, downcase, strip, lstrip, rstrip, strip_newlines, split, replace, replace_first, replace_last, remove, remove_first, remove_last, truncate, truncatewords
|
||||
HTML/URI | escape, escape_once, url_encode, url_decode, strip_html, newline_to_br
|
||||
数组 | slice, map, sort, sort_natural, uniq, wheres, first, last, join, reverse, concat, compact, size, push
|
||||
数组 | slice, map, sort, sort_natural, uniq, wheres, first, last, join, reverse, concat, compact, size, push, pop, shift, unshift
|
||||
日期 | date
|
||||
其他 | default, json
|
||||
|
||||
|
||||
@@ -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
|
||||
```
|
||||
@@ -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
|
||||
```
|
||||
@@ -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
|
||||
```
|
||||
Reference in New Issue
Block a user