mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 04:10:40 -07:00
chore: update build badge, coverage to 100%, mv DEFAULT_FMT to defaultOptions
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
[](https://www.npmjs.org/package/liquidjs)
|
||||
[](https://www.npmjs.org/package/liquidjs)
|
||||
[](https://coveralls.io/github/harttle/liquidjs?branch=master)
|
||||
[](https://github.com/harttle/liquidjs/actions/workflows/check.yml?query=branch%3Amaster)
|
||||
[](https://github.com/harttle/liquidjs/actions/workflows/check.yml?query=branch%3Amaster)
|
||||
[](https://github.com/harttle/liquidjs/blob/master/LICENSE)
|
||||
[](https://github.com/harttle/liquidjs)
|
||||
|
||||
|
||||
@@ -56,6 +56,11 @@
|
||||
<td align="center"><a href="https://github.com/tbdrz"><img src="https://avatars.githubusercontent.com/u/50599116?v=4?s=100" width="100px;" alt=""/></a></td>
|
||||
<td align="center"><a href="http://santialbo.com"><img src="https://avatars.githubusercontent.com/u/1557563?v=4?s=100" width="100px;" alt=""/></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=""/></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=""/></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=""/></a></td>
|
||||
<td align="center"><a href="https://github.com/prassie"><img src="https://avatars.githubusercontent.com/u/1357831?v=4?s=100" width="100px;" alt=""/></a></td>
|
||||
<td align="center"><a href="http://slavv.com/"><img src="https://avatars.githubusercontent.com/u/713329?v=4?s=100" width="100px;" alt=""/></a></td>
|
||||
<td align="center"><a href="http://www.orgflow.io/"><img src="https://avatars.githubusercontent.com/u/3889090?v=4?s=100" width="100px;" alt=""/></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
+1
-3
@@ -1,14 +1,12 @@
|
||||
import { toValue, stringify, isString, isNumber, TimezoneDate, LiquidDate, strftime, isNil } from '../util'
|
||||
import { FilterImpl } from '../template'
|
||||
|
||||
const DEFAULT_FMT = '%A, %B %-e, %Y at %-l:%M %P %z'
|
||||
|
||||
export function date (this: FilterImpl, v: string | Date, format?: string, timezoneOffset?: number | string) {
|
||||
const opts = this.context.opts
|
||||
let date: LiquidDate
|
||||
v = toValue(v)
|
||||
format = toValue(format)
|
||||
if (isNil(format)) format = opts.dateFormat ?? DEFAULT_FMT
|
||||
if (isNil(format)) format = opts.dateFormat
|
||||
else format = stringify(format)
|
||||
if (v === 'now' || v === 'today') {
|
||||
date = new Date()
|
||||
|
||||
@@ -120,6 +120,7 @@ export interface NormalizedFullOptions extends NormalizedOptions {
|
||||
strictVariables: boolean;
|
||||
ownPropertyOnly: boolean;
|
||||
lenientIf: boolean;
|
||||
dateFormat: string;
|
||||
trimTagRight: boolean;
|
||||
trimTagLeft: boolean;
|
||||
trimOutputRight: boolean;
|
||||
@@ -146,6 +147,7 @@ export const defaultOptions: NormalizedFullOptions = {
|
||||
fs: fs,
|
||||
dynamicPartials: true,
|
||||
jsTruthy: false,
|
||||
dateFormat: '%A, %B %-e, %Y at %-l:%M %P %z',
|
||||
trimTagRight: false,
|
||||
trimTagLeft: false,
|
||||
trimOutputRight: false,
|
||||
|
||||
@@ -128,6 +128,14 @@ describe('Context', function () {
|
||||
ctx.push({ foo: Object.create({ bar: 'BAR' }) })
|
||||
return expect(ctx.get(['foo', 'bar'])).to.equal(undefined)
|
||||
})
|
||||
it('should use prototype when ownPropertyOnly=false', function () {
|
||||
ctx = new Context({ foo: Object.create({ bar: 'BAR' }) }, { ownPropertyOnly: false } as any)
|
||||
return expect(ctx.get(['foo', 'bar'])).to.equal('BAR')
|
||||
})
|
||||
it('renderOptions.ownPropertyOnly should override options.ownPropertyOnly', function () {
|
||||
ctx = new Context({ foo: Object.create({ bar: 'BAR' }) }, { ownPropertyOnly: false } as any, { ownPropertyOnly: true })
|
||||
return expect(ctx.get(['foo', 'bar'])).to.equal(undefined)
|
||||
})
|
||||
it('should return undefined for Array.prototype.reduce', function () {
|
||||
ctx.push({ foo: [] })
|
||||
return expect(ctx.get(['foo', 'reduce'])).to.equal(undefined)
|
||||
|
||||
Reference in New Issue
Block a user