mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-20 06:50:47 -07:00
docs: more specific description of strftime
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
title: date
|
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
|
Input
|
||||||
```liquid
|
```liquid
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
title: date
|
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
|
```liquid
|
||||||
|
|||||||
@@ -75,11 +75,17 @@ describe('tags/assign', function () {
|
|||||||
const html = await liquid.parseAndRender(src, { num: 1 })
|
const html = await liquid.parseAndRender(src, { num: 1 })
|
||||||
return expect(html).to.equal('11')
|
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 src = '{%for a in (1..2)%}{%assign num = a%}{{a}}{%endfor%} {{num}}'
|
||||||
const html = await liquid.parseAndRender(src, { num: 1 })
|
const html = await liquid.parseAndRender(src, { num: 1 })
|
||||||
return expect(html).to.equal('12 2')
|
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 () {
|
it('should support sync', function () {
|
||||||
const src = '{% assign foo="bar" %}{{foo}}'
|
const src = '{% assign foo="bar" %}{{foo}}'
|
||||||
|
|||||||
Reference in New Issue
Block a user