mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-16 21:00:40 -07:00
feat: renderSync, parseAndRenderSync and renderFileSync, see #48
This commit is contained in:
@@ -60,4 +60,14 @@ describe('filter', function () {
|
||||
new Filter('/', [], false)
|
||||
}).to.not.throw()
|
||||
})
|
||||
|
||||
it('should support sync', function () {
|
||||
Filter.register('add', (a, b) => a + b)
|
||||
expect(new Filter('add', ['2'], false).renderSync(3, ctx)).to.equal(5)
|
||||
})
|
||||
|
||||
it('should support key value pairs', function () {
|
||||
Filter.register('add', (a, b) => b[0] + ':' + (a + b[1]))
|
||||
expect(new Filter('add', [['num', '2']], false).renderSync(3, ctx)).to.equal('num:5')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
import * as chai from 'chai'
|
||||
import { Hash } from '../../../src/template/tag/hash'
|
||||
import { Context } from '../../../src/context/context'
|
||||
|
||||
const expect = chai.expect
|
||||
|
||||
describe('Hash', function () {
|
||||
it('should parse variable', async function () {
|
||||
const hash = await Hash.create('num:foo', new Context({ foo: 3 }))
|
||||
expect(hash.num).to.equal(3)
|
||||
})
|
||||
it('should parse literals', async function () {
|
||||
const hash = await Hash.create('num:3', new Context())
|
||||
expect(hash.num).to.equal(3)
|
||||
})
|
||||
it('should support sync', function () {
|
||||
const hash = Hash.createSync('num:3', new Context())
|
||||
expect(hash.num).to.equal(3)
|
||||
})
|
||||
})
|
||||
@@ -10,7 +10,7 @@ chai.use(sinonChai)
|
||||
const expect = chai.expect
|
||||
const liquid = new Liquid()
|
||||
|
||||
describe('tag', function () {
|
||||
describe('Tag', function () {
|
||||
let ctx: Context
|
||||
const emitter = { write: (html: string) => (emitter.html += html), html: '' }
|
||||
before(function () {
|
||||
|
||||
Reference in New Issue
Block a user