chore(TypeScript): ship Liquid to class

BREAKING CHANGE: calling `Liquid()` without `new` now becomes invalid
This commit is contained in:
harttle
2019-02-14 23:53:40 +08:00
parent a626de632c
commit 1cc7249a71
27 changed files with 124 additions and 126 deletions
+2 -2
View File
@@ -9,7 +9,7 @@ chai.use(chaiAsPromised)
describe('cache options', function () {
let engine
beforeEach(function () {
engine = Liquid({
engine = new Liquid({
root: '/root/',
extname: '.html'
})
@@ -28,7 +28,7 @@ describe('cache options', function () {
.then(x => expect(x).to.equal('bar'))
})
it('should respect cache=true option', function () {
engine = Liquid({
engine = new Liquid({
root: '/root/',
extname: '.html',
cache: true
+1 -1
View File
@@ -8,7 +8,7 @@ describe('strict options', function () {
let engine
const ctx = {}
beforeEach(function () {
engine = Liquid({
engine = new Liquid({
root: '/root/',
extname: '.html'
})
+10 -10
View File
@@ -10,34 +10,34 @@ describe('trimming', function () {
describe('tag trimming', function () {
it('should respect trim_tag_left', function () {
const engine = Liquid({ trim_tag_left: true })
const engine = new Liquid({ trim_tag_left: true })
return expect(engine.parseAndRender(' \n \t{%if true%}foo{%endif%} '))
.to.eventually.equal('foo ')
})
it('should respect trim_tag_right', function () {
const engine = Liquid({ trim_tag_right: true })
const engine = new Liquid({ trim_tag_right: true })
return expect(engine.parseAndRender('\t{%if true%}foo{%endif%} \n'))
.to.eventually.equal('\tfoo')
})
it('should not trim value', function () {
const engine = Liquid({ trim_tag_left: true, trim_tag_right: true })
const engine = new Liquid({ trim_tag_left: true, trim_tag_right: true })
return expect(engine.parseAndRender('{%if true%}a {{name}} b{%endif%}', ctx))
.to.eventually.equal('a harttle b')
})
})
describe('value trimming', function () {
it('should respect trim_value_left', function () {
const engine = Liquid({ trim_value_left: true })
const engine = new Liquid({ trim_value_left: true })
return expect(engine.parseAndRender(' \n \t{{name}} ', ctx))
.to.eventually.equal('harttle ')
})
it('should respect trim_value_right', function () {
const engine = Liquid({ trim_value_right: true })
const engine = new Liquid({ trim_value_right: true })
return expect(engine.parseAndRender(' \n \t{{name}} ', ctx))
.to.eventually.equal(' \n \tharttle')
})
it('should respect not trim tag', function () {
const engine = Liquid({ trim_value_left: true, trim_value_right: true })
const engine = new Liquid({ trim_value_left: true, trim_value_right: true })
return expect(engine.parseAndRender('\t{% if true %} aha {%endif%}\t'))
.to.eventually.equal('\t aha \t')
})
@@ -45,19 +45,19 @@ describe('trimming', function () {
describe('greedy', function () {
const src = '\n {%-if true-%}\n a \n{{-name-}}{%-endif-%}\n '
it('should enable greedy by default', function () {
const engine = Liquid()
const engine = new Liquid()
return expect(engine.parseAndRender(src, ctx))
.to.eventually.equal('aharttle')
})
it('should respect to greedy:false by default', function () {
const engine = Liquid({ greedy: false })
const engine = new Liquid({ greedy: false })
return expect(engine.parseAndRender(src, ctx))
.to.eventually.equal('\n a \nharttle ')
})
})
describe('markup', function () {
it('should support trim using markup', function () {
const engine = Liquid()
const engine = new Liquid()
const src = [
'{%- assign username = "John G. Chalmers-Smith" -%}',
'{%- if username and username.length > 10 -%}',
@@ -70,7 +70,7 @@ describe('trimming', function () {
return expect(engine.parseAndRender(src)).to.eventually.equal(dst)
})
it('should not trim when not specified', function () {
const engine = Liquid()
const engine = new Liquid()
const src = [
'{% assign username = "John G. Chalmers-Smith" %}',
'{% if username and username.length > 10 %}',