Skip to content

Commit

Permalink
docs: add docs for push filter
Browse files Browse the repository at this point in the history
  • Loading branch information
harttle committed Apr 14, 2024
1 parent ccd83bc commit 18d5592
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 87 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ node_modules/

# tmp
docs/public/js/liquid.browser.min.js
docs/themes/navy/layout/partial/all-contributors.swig
dist/
demo/*/yarn.json

Expand Down
1 change: 1 addition & 0 deletions docs/source/_data/sidebar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/source/filters/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
25 changes: 25 additions & 0 deletions docs/source/filters/push.md
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
```
2 changes: 1 addition & 1 deletion docs/source/zh-cn/filters/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
25 changes: 25 additions & 0 deletions docs/source/zh-cn/filters/push.md
Original file line number Diff line number Diff line change
@@ -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
```
85 changes: 0 additions & 85 deletions docs/themes/navy/layout/partial/all-contributors.swig

This file was deleted.

0 comments on commit 18d5592

Please sign in to comment.