Skip to content

Commit

Permalink
chore: update build badge, coverage to 100%, mv DEFAULT_FMT to defaul…
Browse files Browse the repository at this point in the history
…tOptions
  • Loading branch information
harttle committed Feb 22, 2023
1 parent 5f4a004 commit d4e519c
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
5 changes: 5 additions & 0 deletions docs/themes/navy/layout/partial/all-contributors.swig
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
4 changes: 1 addition & 3 deletions src/filters/date.ts
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
2 changes: 2 additions & 0 deletions src/liquid-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export interface NormalizedFullOptions extends NormalizedOptions {
strictVariables: boolean;
ownPropertyOnly: boolean;
lenientIf: boolean;
dateFormat: string;
trimTagRight: boolean;
trimTagLeft: boolean;
trimOutputRight: boolean;
Expand All @@ -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,
Expand Down
8 changes: 8 additions & 0 deletions test/unit/context/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d4e519c

Please sign in to comment.