Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: harttle/liquidjs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v9.39.1
Choose a base ref
...
head repository: harttle/liquidjs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v9.39.2
Choose a head ref
  • 3 commits
  • 6 files changed
  • 3 contributors

Commits on Jul 20, 2022

  1. Verified

    This commit was signed with the committer’s verified signature.
    dtolnay David Tolnay
    Copy the full SHA
    4ad383d View commit details

Commits on Jul 21, 2022

  1. chore(deps): bump terser from 4.6.7 to 4.8.1 in /docs

    Bumps [terser](https://github.com/terser/terser) from 4.6.7 to 4.8.1.
    - [Release notes](https://github.com/terser/terser/releases)
    - [Changelog](https://github.com/terser/terser/blob/master/CHANGELOG.md)
    - [Commits](https://github.com/terser/terser/commits)
    
    ---
    updated-dependencies:
    - dependency-name: terser
      dependency-type: indirect
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and harttle committed Jul 21, 2022

    Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    0a1d604 View commit details
  2. chore(release): 9.39.2 [skip ci]

    ## [9.39.2](v9.39.1...v9.39.2) (2022-07-21)
    
    ### Bug Fixes
    
    * expression support Drop.valueOf, fixes [#522](#522) ([4ad383d](4ad383d))
    semantic-release-bot committed Jul 21, 2022
    Copy the full SHA
    753e8f9 View commit details
Showing with 35 additions and 16 deletions.
  1. +7 −0 CHANGELOG.md
  2. +6 −6 docs/package-lock.json
  3. +1 −1 package-lock.json
  4. +1 −1 package.json
  5. +8 −8 src/render/operator.ts
  6. +12 −0 test/integration/drop/drop.ts
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## [9.39.2](https://github.com/harttle/liquidjs/compare/v9.39.1...v9.39.2) (2022-07-21)


### Bug Fixes

* expression support Drop.valueOf, fixes [#522](https://github.com/harttle/liquidjs/issues/522) ([4ad383d](https://github.com/harttle/liquidjs/commit/4ad383d9beb57f5683805decc1851778db64aea4))

## [9.39.1](https://github.com/harttle/liquidjs/compare/v9.39.0...v9.39.1) (2022-07-14)


12 changes: 6 additions & 6 deletions docs/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "liquidjs",
"version": "9.39.1",
"version": "9.39.2",
"description": "A simple, expressive and safe Shopify / Github Pages compatible template engine in pure JavaScript.",
"main": "dist/liquid.node.cjs.js",
"module": "dist/liquid.node.esm.js",
16 changes: 8 additions & 8 deletions src/render/operator.ts
Original file line number Diff line number Diff line change
@@ -11,38 +11,38 @@ export const defaultOperators: Operators = {
'==': (l: any, r: any) => {
if (isComparable(l)) return l.equals(r)
if (isComparable(r)) return r.equals(l)
return l === r
return toValue(l) === toValue(r)
},
'!=': (l: any, r: any) => {
if (isComparable(l)) return !l.equals(r)
if (isComparable(r)) return !r.equals(l)
return l !== r
return toValue(l) !== toValue(r)
},
'>': (l: any, r: any) => {
if (isComparable(l)) return l.gt(r)
if (isComparable(r)) return r.lt(l)
return l > r
return toValue(l) > toValue(r)
},
'<': (l: any, r: any) => {
if (isComparable(l)) return l.lt(r)
if (isComparable(r)) return r.gt(l)
return l < r
return toValue(l) < toValue(r)
},
'>=': (l: any, r: any) => {
if (isComparable(l)) return l.geq(r)
if (isComparable(r)) return r.leq(l)
return l >= r
return toValue(l) >= toValue(r)
},
'<=': (l: any, r: any) => {
if (isComparable(l)) return l.leq(r)
if (isComparable(r)) return r.geq(l)
return l <= r
return toValue(l) <= toValue(r)
},
'contains': (l: any, r: any) => {
l = toValue(l)
r = toValue(r)
return l && isFunction(l.indexOf) ? l.indexOf(r) > -1 : false
},
'and': (l: any, r: any, ctx: Context) => isTruthy(l, ctx) && isTruthy(r, ctx),
'or': (l: any, r: any, ctx: Context) => isTruthy(l, ctx) || isTruthy(r, ctx)
'and': (l: any, r: any, ctx: Context) => isTruthy(toValue(l), ctx) && isTruthy(toValue(r), ctx),
'or': (l: any, r: any, ctx: Context) => isTruthy(toValue(l), ctx) || isTruthy(toValue(r), ctx)
}
12 changes: 12 additions & 0 deletions test/integration/drop/drop.ts
Original file line number Diff line number Diff line change
@@ -72,4 +72,16 @@ describe('drop/drop', function () {
const html = await liquid.parseAndRender(tpl, { drop: new CustomDrop() })
expect(html).to.equal('foobar: foo;bar;')
})
it('should support valueOf in == expression', async () => {
class AddressDrop extends Drop {
valueOf () {
return 'test'
}
}
const address = new AddressDrop()
const customer = { default_address: new AddressDrop() }
const tpl = `{% if address == customer.default_address %}{{address}}{% endif %}`
const html = await liquid.parseAndRender(tpl, { address, customer })
expect(html).to.equal('test')
})
})