Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: harttle/liquidjs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v9.42.1
Choose a base ref
...
head repository: harttle/liquidjs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v9.43.0
Choose a head ref
  • 7 commits
  • 12 files changed
  • 6 contributors

Commits on Oct 22, 2022

  1. docs: add echo and liquid tags Chinese translation (#549)

    * docs: add echo and liquid tags chinese translation
    
    * Update docs/source/zh-cn/tags/echo.md
    
    Co-authored-by: Jun Yang <harttleharttle@gmail.com>
    
    * Update docs/source/zh-cn/tags/echo.md
    
    Co-authored-by: Jun Yang <harttleharttle@gmail.com>
    
    * Update docs/source/zh-cn/tags/echo.md
    
    Co-authored-by: Jun Yang <harttleharttle@gmail.com>
    
    * Update Liquid.md
    
    * Update Liquid.md
    
    Co-authored-by: Jun Yang <harttleharttle@gmail.com>
    zxx457 and harttle authored Oct 22, 2022

    Verified

    This commit was signed with the committer’s verified signature.
    dtolnay David Tolnay
    Copy the full SHA
    f62b210 View commit details
  2. Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    9cfc8fd View commit details
  3. Copy the full SHA
    33e97db View commit details

Commits on Oct 23, 2022

  1. Copy the full SHA
    8061e55 View commit details

Commits on Nov 14, 2022

  1. chore(deps): bump minimatch from 3.0.4 to 3.1.2 in /docs

    Bumps [minimatch](https://github.com/isaacs/minimatch) from 3.0.4 to 3.1.2.
    - [Release notes](https://github.com/isaacs/minimatch/releases)
    - [Commits](isaacs/minimatch@v3.0.4...v3.1.2)
    
    ---
    updated-dependencies:
    - dependency-name: minimatch
      dependency-type: indirect
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and harttle committed Nov 14, 2022
    Copy the full SHA
    cd918cc View commit details

Commits on Nov 27, 2022

  1. Copy the full SHA
    7a71485 View commit details
  2. chore(release): 9.43.0 [skip ci]

    # [9.43.0](v9.42.1...v9.43.0) (2022-11-27)
    
    ### Features
    
    * support timezone offset argument for date filter, [#553](#553) ([7a71485](7a71485))
    semantic-release-bot committed Nov 27, 2022
    Copy the full SHA
    907c4de View commit details
9 changes: 9 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
@@ -504,6 +504,15 @@
"contributions": [
"doc"
]
},
{
"login": "zxx-457",
"name": "zxx-457",
"avatar_url": "https://avatars.githubusercontent.com/u/114141362?v=4",
"profile": "https://github.com/zxx-457",
"contributions": [
"doc"
]
}
],
"contributorsPerLine": 7,
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# [9.43.0](https://github.com/harttle/liquidjs/compare/v9.42.1...v9.43.0) (2022-11-27)


### Features

* support timezone offset argument for date filter, [#553](https://github.com/harttle/liquidjs/issues/553) ([7a71485](https://github.com/harttle/liquidjs/commit/7a714855df9ba188e2e82839d248f6623ce94a87))

## [9.42.1](https://github.com/harttle/liquidjs/compare/v9.42.0...v9.42.1) (2022-10-21)


1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -142,6 +142,7 @@ Want to contribute? see [Contribution Guidelines][contribution]. Thanks goes to
<td align="center"><a href="http://santialbo.com"><img src="https://avatars.githubusercontent.com/u/1557563?v=4?s=100" width="100px;" alt="Santi Albo"/><br /><sub><b>Santi Albo</b></sub></a><br /><a href="https://github.com/harttle/liquidjs/commits?author=santialbo" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/YahangWu"><img src="https://avatars.githubusercontent.com/u/12295975?v=4?s=100" width="100px;" alt="Yahang Wu"/><br /><sub><b>Yahang Wu</b></sub></a><br /><a href="https://github.com/harttle/liquidjs/commits?author=YahangWu" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/hongl-1"><img src="https://avatars.githubusercontent.com/u/101576612?v=4?s=100" width="100px;" alt="hongl"/><br /><sub><b>hongl</b></sub></a><br /><a href="https://github.com/harttle/liquidjs/commits?author=hongl-1" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/zxx-457"><img src="https://avatars.githubusercontent.com/u/114141362?v=4?s=100" width="100px;" alt="zxx-457"/><br /><sub><b>zxx-457</b></sub></a><br /><a href="https://github.com/harttle/liquidjs/commits?author=zxx-457" title="Documentation">📖</a></td>
</tr>
</tbody>
</table>
12 changes: 6 additions & 6 deletions docs/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/source/_data/sidebar.yml
Original file line number Diff line number Diff line change
@@ -78,7 +78,7 @@ filters:

tags:
overview: overview.html
"# (inline comment)": inline_comment.html
"#": inline_comment.html
assign: assign.html
capture: capture.html
case: case.html
20 changes: 20 additions & 0 deletions docs/source/zh-cn/tags/echo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
title: Echo
---

{% since %}v9.31.0{% endsince %}

根据表达式输出渲染 HTML。和使用 `{{` expression `}}` 包裹模板效果一样,不同的是 echo 可以在 liquid 标签中使用,同时也支持过滤器。

## echo

输入
```liquid
{% assign username = 'Bob' %}
{% echo username | append: ", welcome to LiquidJS!" | capitalize %}
```

输出
```text
Bob, welcome to LiquidJS!
```
28 changes: 28 additions & 0 deletions docs/source/zh-cn/tags/liquid.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
title: Liquid
---

{% since %}v9.31.0{% endsince %}

通过 liquid 标签可以在一个分隔符中使用多个标签, 使 Liquid 逻辑书写更简洁。

## liquid

输入
```liquid
{% liquid
assign names = 'Bob, Sally' | split: ', '
for name in names
echo 'Hello, ' | append: name
unless forloop.last
echo ', '
endunless
endfor
%}
```

输出
```text
Hello, Bob, Hello Sally
```
1 change: 0 additions & 1 deletion docs/themes/navy/languages/zh-cn.yml
Original file line number Diff line number Diff line change
@@ -59,7 +59,6 @@ sidebar:
overview: 概述
tags:
overview: 概述
'# (inline comment)': '#(单行注释)'
api:
quick_entry: 快速入口
classes:
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "liquidjs",
"version": "9.42.1",
"version": "9.43.0",
"description": "A simple, expressive and safe Shopify / Github Pages compatible template engine in pure JavaScript.",
"main": "dist/liquid.node.cjs.js",
"module": "dist/liquid.node.esm.js",
10 changes: 6 additions & 4 deletions src/builtin/filters/date.ts
Original file line number Diff line number Diff line change
@@ -4,11 +4,11 @@ import { toValue, stringify, isString, isNumber } from '../../util/underscore'
import { FilterImpl } from '../../template/filter/filter-impl'
import { TimezoneDate } from '../../util/timezone-date'

export function date (this: FilterImpl, v: string | Date, arg: string) {
export function date (this: FilterImpl, v: string | Date, format: string, timeZoneOffset?: number) {
const opts = this.context.opts
let date: LiquidDate
v = toValue(v)
arg = stringify(arg)
format = stringify(format)
if (v === 'now' || v === 'today') {
date = new Date()
} else if (isNumber(v)) {
@@ -25,10 +25,12 @@ export function date (this: FilterImpl, v: string | Date, arg: string) {
date = v
}
if (!isValidDate(date)) return v
if (opts.hasOwnProperty('timezoneOffset')) {
if (timeZoneOffset !== undefined) {
date = new TimezoneDate(date, timeZoneOffset)
} else if (opts.timezoneOffset !== undefined) {
date = new TimezoneDate(date, opts.timezoneOffset!)
}
return strftime(date, arg)
return strftime(date, format)
}

function isValidDate (date: any): date is Date {
3 changes: 3 additions & 0 deletions test/integration/builtin/filters/date.ts
Original file line number Diff line number Diff line change
@@ -61,6 +61,9 @@ describe('filters/date', function () {
it('should offset UTC date literal', function () {
return test('{{ "1990-12-31T23:00:00Z" | date: "%Y-%m-%dT%H:%M:%S"}}', '1990-12-31T17:00:00', undefined, opts)
})
it('should support timezone offset argument', function () {
return test('{{ "1990-12-31T23:00:00Z" | date: "%Y-%m-%dT%H:%M:%S", 360}}', '1990-12-31T17:00:00')
})
it('should offset date literal with timezone 00:00 specified', function () {
return test('{{ "1990-12-31T23:00:00+00:00" | date: "%Y-%m-%dT%H:%M:%S"}}', '1990-12-31T17:00:00', undefined, opts)
})