From 2fa4edaa84ea1cd76c27a171f0719105f94878f9 Mon Sep 17 00:00:00 2001 From: harttle Date: Sun, 19 Apr 2020 13:15:11 +0800 Subject: [PATCH] docs: more specific description of strftime --- docs/source/filters/date.md | 2 +- docs/source/zh-cn/filters/date.md | 2 +- test/integration/builtin/tags/assign.ts | 8 +++++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/docs/source/filters/date.md b/docs/source/filters/date.md index 5af5f3cdd..48097ff84 100644 --- a/docs/source/filters/date.md +++ b/docs/source/filters/date.md @@ -2,7 +2,7 @@ title: date --- -Converts a timestamp into another date format. The format for this syntax is the same as [`strftime`](http://strftime.net). The input is first converted to Date object by [new Date()][newDate]. +Converts a timestamp into another date format. LiquidJS tries to be conformant with Shopify/Liquid which is using Ruby's core [Time#strftime(string)](http://www.ruby-doc.org/core/Time.html#method-i-strftime). The input is firstly converted to `Date` object via [new Date()][newDate]. Input ```liquid diff --git a/docs/source/zh-cn/filters/date.md b/docs/source/zh-cn/filters/date.md index 823926042..2fb6926b5 100644 --- a/docs/source/zh-cn/filters/date.md +++ b/docs/source/zh-cn/filters/date.md @@ -2,7 +2,7 @@ title: date --- -把时间戳转换为字符串,这一语法的格式同 [`strftime`](http://strftime.net)。LiquidJS 会先通过 [new Date()][newDate] 尝试把输入转换为 Date 对象。 +把时间戳转换为字符串。LiquidJS 尝试跟 Shopify/Liquid 保持一致,它用的是 Ruby 核心的 [Time#strftime(string)](http://www.ruby-doc.org/core/Time.html#method-i-strftime)。此外 LiquidJS 会先通过 [new Date()][newDate] 尝试把输入转换为 Date 对象。 输入 ```liquid diff --git a/test/integration/builtin/tags/assign.ts b/test/integration/builtin/tags/assign.ts index 60115971b..eeeaf977e 100644 --- a/test/integration/builtin/tags/assign.ts +++ b/test/integration/builtin/tags/assign.ts @@ -75,11 +75,17 @@ describe('tags/assign', function () { const html = await liquid.parseAndRender(src, { num: 1 }) return expect(html).to.equal('11') }) - it('should write to the belonging scope', async function () { + it('should write to the root scope', async function () { const src = '{%for a in (1..2)%}{%assign num = a%}{{a}}{%endfor%} {{num}}' const html = await liquid.parseAndRender(src, { num: 1 }) return expect(html).to.equal('12 2') }) + it('should not change input scope', async function () { + const src = '{%for a in (1..2)%}{%assign num = a%}{{a}}{%endfor%} {{num}}' + const ctx = { num: 1 } + await liquid.parseAndRender(src, ctx) + return expect(ctx.num).to.equal(1) + }) }) it('should support sync', function () { const src = '{% assign foo="bar" %}{{foo}}'