diff --git a/README.md b/README.md index f34945225..5318a7b16 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![npm version](https://img.shields.io/npm/v/liquidjs.svg?logo=npm&style=flat-square)](https://www.npmjs.org/package/liquidjs) [![npm downloads](https://img.shields.io/npm/dm/liquidjs.svg?style=flat-square)](https://www.npmjs.org/package/liquidjs) [![Coverage](https://img.shields.io/coveralls/harttle/liquidjs.svg?style=flat-square)](https://coveralls.io/github/harttle/liquidjs?branch=master) -[![Build Status](https://img.shields.io/github/workflow/status/harttle/liquidjs/Check/master.svg?style=flat-square)](https://github.com/harttle/liquidjs/actions/workflows/check.yml?query=branch%3Amaster) +[![Build Status](https://img.shields.io/github/actions/workflow/status/harttle/liquidjs/check.yml?branch=master&style=flat-square)](https://github.com/harttle/liquidjs/actions/workflows/check.yml?query=branch%3Amaster) [![DUB license](https://img.shields.io/dub/l/vibe-d.svg?style=flat-square)](https://github.com/harttle/liquidjs/blob/master/LICENSE) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)](https://github.com/harttle/liquidjs) diff --git a/docs/themes/navy/layout/partial/all-contributors.swig b/docs/themes/navy/layout/partial/all-contributors.swig index 589f4e17e..51ae62355 100644 --- a/docs/themes/navy/layout/partial/all-contributors.swig +++ b/docs/themes/navy/layout/partial/all-contributors.swig @@ -56,6 +56,11 @@ + + + + + diff --git a/src/filters/date.ts b/src/filters/date.ts index 6483590c7..0f7360814 100644 --- a/src/filters/date.ts +++ b/src/filters/date.ts @@ -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() diff --git a/src/liquid-options.ts b/src/liquid-options.ts index 5e45620f2..510e010c0 100644 --- a/src/liquid-options.ts +++ b/src/liquid-options.ts @@ -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, diff --git a/test/unit/context/context.ts b/test/unit/context/context.ts index 3436334fa..c5099498c 100644 --- a/test/unit/context/context.ts +++ b/test/unit/context/context.ts @@ -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)