docs: more specific description of strftime

This commit is contained in:
harttle
2020-04-19 13:15:11 +08:00
parent 83b46bd25d
commit 2fa4edaa84
3 changed files with 9 additions and 3 deletions
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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
+7 -1
View File
@@ -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}}'