mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-17 21:40:39 -07:00
feat: date filters from Jekyll
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
---
|
||||
title: date_to_long_string
|
||||
---
|
||||
{% since %}v10.13.0{% endsince %}
|
||||
|
||||
把日期转换为长格式(只支持 US/UK 两种),与 Jekyll 的 `date_to_long_string` 过滤器一样。
|
||||
|
||||
输入
|
||||
```liquid
|
||||
{{ site.time | date_to_long_string }}
|
||||
```
|
||||
|
||||
输出
|
||||
```text
|
||||
07 November 2008
|
||||
```
|
||||
|
||||
输入
|
||||
```liquid
|
||||
{{ site.time | date_to_long_string: "ordinal" }}
|
||||
```
|
||||
|
||||
输出
|
||||
```text
|
||||
7th November 2008
|
||||
```
|
||||
|
||||
|
||||
注意 JavaScript `Date` 没有时区信息,详情请参考 [date][date] 过滤器。
|
||||
|
||||
[date]: ./date.html
|
||||
@@ -0,0 +1,20 @@
|
||||
---
|
||||
title: date_to_rfc822
|
||||
---
|
||||
{% since %}v10.13.0{% endsince %}
|
||||
|
||||
把日期转换为 RFC-822 格式用于 RSS feed,与 Jekyll 的 `date_to_rfc822` 过滤器一样。
|
||||
|
||||
输入
|
||||
```liquid
|
||||
{{ site.time | date_to_rfc822 }}
|
||||
```
|
||||
|
||||
输入
|
||||
```text
|
||||
Mon, 07 Nov 2008 13:07:54 -0800
|
||||
```
|
||||
|
||||
注意 JavaScript `Date` 没有时区信息,详情请参考 [date][date] 过滤器。
|
||||
|
||||
[date]: ./date.html
|
||||
@@ -0,0 +1,30 @@
|
||||
---
|
||||
title: date_to_string
|
||||
---
|
||||
{% since %}v10.13.0{% endsince %}
|
||||
|
||||
把日期转换为短格式(只支持 US/UK 两种),与 Jekyll 的 `date_to_string` 过滤器一样。
|
||||
|
||||
输入
|
||||
```liquid
|
||||
{{ site.time | date_to_string }}
|
||||
```
|
||||
|
||||
输出
|
||||
```text
|
||||
07 Nov 2008
|
||||
```
|
||||
|
||||
输入
|
||||
```liquid
|
||||
{{ site.time | date_to_string: "ordinal", "US" }}
|
||||
```
|
||||
|
||||
输出
|
||||
```text
|
||||
Nov 7th, 2008
|
||||
```
|
||||
|
||||
注意 JavaScript `Date` 没有时区信息,详情请参考 [date][date] 过滤器。
|
||||
|
||||
[date]: ./date.html
|
||||
@@ -0,0 +1,20 @@
|
||||
---
|
||||
title: date_to_xmlschema
|
||||
---
|
||||
{% since %}v10.13.0{% endsince %}
|
||||
|
||||
把日期转换为 XML Schema (ISO 8601) 格式,与 Jekyll 的 `date_to_xmlschema` 过滤器一样。
|
||||
|
||||
输入
|
||||
```liquid
|
||||
{{ site.time | date_to_xmlschema }}
|
||||
```
|
||||
|
||||
输出
|
||||
```text
|
||||
2008-11-07T13:07:54-08:00
|
||||
```
|
||||
|
||||
注意 JavaScript `Date` 没有时区信息,详情请参考 [date][date] 过滤器。
|
||||
|
||||
[date]: ./date.html
|
||||
@@ -13,7 +13,7 @@ LiquidJS 共支持 40+ 个过滤器,可以分为如下几类:
|
||||
字符串 | append, prepend, capitalize, upcase, downcase, strip, lstrip, rstrip, strip_newlines, split, replace, replace_first, replace_last, remove, remove_first, remove_last, truncate, truncatewords, normalize_whitespace
|
||||
HTML/URI | escape, escape_once, url_encode, url_decode, strip_html, newline_to_br
|
||||
数组 | slice, map, sort, sort_natural, uniq, where, where_exp, group_by, group_by_exp, find, find_exp, first, last, join, reverse, concat, compact, size, push, pop, shift, unshift
|
||||
日期 | date
|
||||
日期 | date, date_to_xmlschema, date_to_rfc822, date_to_string, date_to_long_string
|
||||
其他 | default, json, jsonify, inspect, raw, to_integer
|
||||
|
||||
[shopify/liquid]: https://github.com/Shopify/liquid
|
||||
|
||||
Reference in New Issue
Block a user