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.40.0
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.41.0
Choose a head ref
  • 3 commits
  • 6 files changed
  • 3 contributors

Commits on Aug 20, 2022

  1. chore(deps): bump path-parse and path-parse

    Bumps [path-parse](https://github.com/jbgutierrez/path-parse) and [path-parse](https://github.com/jbgutierrez/path-parse). These dependencies needed to be updated together.
    
    Updates `path-parse` from 1.0.7 to 1.0.7
    - [Release notes](https://github.com/jbgutierrez/path-parse/releases)
    - [Commits](jbgutierrez/path-parse@v1.0.7...v1.0.7)
    
    Updates `path-parse` from 1.0.6 to 1.0.7
    - [Release notes](https://github.com/jbgutierrez/path-parse/releases)
    - [Commits](jbgutierrez/path-parse@v1.0.7...v1.0.7)
    
    ---
    updated-dependencies:
    - dependency-name: path-parse
      dependency-type: indirect
    - dependency-name: path-parse
      dependency-type: indirect
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and harttle committed Aug 20, 2022

    Verified

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

Commits on Aug 24, 2022

  1. Unverified

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

    # [9.41.0](v9.40.0...v9.41.0) (2022-08-24)
    
    ### Features
    
    * use evalValue to parse & render expression, [#527](#527) ([071368a](071368a))
    semantic-release-bot committed Aug 24, 2022
    Copy the full SHA
    0997530 View commit details
Showing with 50 additions and 765 deletions.
  1. +7 −0 CHANGELOG.md
  2. +2 −755 package-lock.json
  3. +1 −1 package.json
  4. +6 −5 src/liquid.ts
  5. +24 −4 test/e2e/eval-value.ts
  6. +10 −0 test/e2e/issues.ts
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# [9.41.0](https://github.com/harttle/liquidjs/compare/v9.40.0...v9.41.0) (2022-08-24)


### Features

* use evalValue to parse & render expression, [#527](https://github.com/harttle/liquidjs/issues/527) ([071368a](https://github.com/harttle/liquidjs/commit/071368afe1c4fd36ebdb0e1d300c367db1766f7f))

# [9.40.0](https://github.com/harttle/liquidjs/compare/v9.39.2...v9.40.0) (2022-08-14)


757 changes: 2 additions & 755 deletions package-lock.json

Large diffs are not rendered by default.

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.40.0",
"version": "9.41.0",
"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",
11 changes: 6 additions & 5 deletions src/liquid.ts
Original file line number Diff line number Diff line change
@@ -90,15 +90,16 @@ export class Liquid {
return this.renderToNodeStream(templates, scope, renderOptions)
}

public _evalValue (str: string, ctx: Context): IterableIterator<any> {
public _evalValue (str: string, scopeOrContext?: object | Context): IterableIterator<any> {
const value = new Value(str, this)
const ctx = scopeOrContext instanceof Context ? scopeOrContext : new Context(scopeOrContext, this.options)
return value.value(ctx, false)
}
public async evalValue (str: string, ctx: Context): Promise<any> {
return toPromise(this._evalValue(str, ctx))
public async evalValue (str: string, scopeOrContext?: object | Context): Promise<any> {
return toPromise(this._evalValue(str, scopeOrContext))
}
public evalValueSync (str: string, ctx: Context): any {
return toValueSync(this._evalValue(str, ctx))
public evalValueSync (str: string, scopeOrContext?: object | Context): any {
return toValueSync(this._evalValue(str, scopeOrContext))
}

public registerFilter (name: string, filter: FilterImplOptions) {
28 changes: 24 additions & 4 deletions test/e2e/eval-value.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,32 @@
import { expect } from 'chai'
import { Liquid } from '../..'
import { Context, Liquid } from '../..'

describe('#evalValue()', function () {
var engine: Liquid
beforeEach(() => { engine = new Liquid() })
beforeEach(() => { engine = new Liquid({ globals: { foo: 'FOO' } }) })

it('should eval value', async function () {
const val = await engine.evalValue('true', { opts: {} } as any)
it('should support boolean', async function () {
const val = await engine.evalValue('true')
expect(val).to.equal(true)
})

it('should support binary expression with Context', async function () {
const val = await engine.evalValue('a > b', { a: 1, b: 2 })
expect(val).to.equal(false)
})

it('should inherit Liquid options', async function () {
const val = await engine.evalValue('foo')
expect(val).to.equal('FOO')
})

it('should support passing Context', async function () {
const val = await engine.evalValue('a > b', new Context({ a: 1, b: 2 }))
expect(val).to.equal(false)
})

it('should respect options in passed in Context', async function () {
const val = await engine.evalValue('foo', new Context({}, { globals: { foo: 'BAR' } } as any))
expect(val).to.equal('BAR')
})
})
10 changes: 10 additions & 0 deletions test/e2e/issues.ts
Original file line number Diff line number Diff line change
@@ -266,4 +266,14 @@ describe('Issues', function () {
const result = toValueSync(expression.evaluate(new Context({ a: 1, b: 2 })))
expect(result).to.equal(false)
})
it('#527 export Liquid Expression (evalValue)', async () => {
const liquid = new Liquid()
const result = await liquid.evalValue('a > b', { a: 1, b: 2 })
expect(result).to.equal(false)
})
it('#527 export Liquid Expression (evalValueSync)', async () => {
const liquid = new Liquid()
const result = liquid.evalValueSync('a > b', { a: 1, b: 2 })
expect(result).to.equal(false)
})
})