docs: add docs for push filter

This commit is contained in:
Jun Yang
2024-04-14 19:34:07 +08:00
parent ccd83bc6bd
commit 18d55929e5
7 changed files with 54 additions and 87 deletions
+1
View File
@@ -51,6 +51,7 @@ filters:
modulo: modulo.html
newline_to_br: newline_to_br.html
plus: plus.html
push: push.html
prepend: prepend.html
raw: raw.html
remove: remove.html
+1 -1
View File
@@ -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
Array | slice, map, sort, sort_natural, uniq, where, first, last, join, reverse, concat, compact, size, push
Date | date
Misc | default, json, raw
+25
View File
@@ -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
```
+1 -1
View File
@@ -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
数组 | slice, map, sort, sort_natural, uniq, wheres, first, last, join, reverse, concat, compact, size, push
日期 | date
其他 | default, json
+25
View File
@@ -0,0 +1,25 @@
---
title: push
---
{% since %}v10.8.0{% endsince %}
在数组中添加一个元素。注意该操作不会改变原数组,而是在一份拷贝上操作。
输入
```liquid
{% assign fruits = "apples, oranges" | split: ", " %}
{% assign everything = fruits | push: "peaches" %}
{% for item in everything %}
- {{ item }}
{% endfor %}
```
输出
```text
- apples
- oranges
- peaches
```