feat: exported Drop interface for #107

Deprecate snake_cased options and APIs, sed #109
This commit is contained in:
harttle
2019-02-28 00:05:08 +08:00
parent b69c3a3203
commit 7bee9fc92d
26 changed files with 227 additions and 179 deletions
+8 -8
View File
@@ -4,26 +4,26 @@ import Liquid from '../../../src/liquid'
describe('LiquidOptions#*_delimiter_*', function () {
it('should respect tag_delimiter_*', async function () {
const engine = new Liquid({
tag_delimiter_left: '<%=',
tag_delimiter_right: '%>'
tagDelimiterLeft: '<%=',
tagDelimiterRight: '%>'
})
const html = await engine.parseAndRender('<%=if true%>foo<%=endif%> ')
return expect(html).to.equal('foo ')
})
it('should respect output_delimiter_*', async function () {
const engine = new Liquid({
output_delimiter_left: '<<',
output_delimiter_right: '>>'
outputDelimiterLeft: '<<',
outputDelimiterRight: '>>'
})
const html = await engine.parseAndRender('<< "liquid" | capitalize >>')
return expect(html).to.equal('Liquid')
})
it('should support trimming with tag_delimiter_* set', async function () {
const engine = new Liquid({
tag_delimiter_left: '<%=',
tag_delimiter_right: '%>',
trim_tag_left: true,
trim_tag_right: true
tagDelimiterLeft: '<%=',
tagDelimiterRight: '%>',
trimTagLeft: true,
trimTagRight: true
})
const html = await engine.parseAndRender(' <%=if true%> \tfoo\t <%=endif%> ')
return expect(html).to.equal('foo')
+5 -5
View File
@@ -10,22 +10,22 @@ describe('LiquidOptions#strict_*', function () {
extname: '.html'
})
})
it('should not throw when strict_variables false (default)', async function () {
it('should not throw when strictVariables false (default)', async function () {
const html = await engine.parseAndRender('before{{notdefined}}after', ctx)
return expect(html).to.equal('beforeafter')
})
it('should throw when strict_variables true', function () {
it('should throw when strictVariables true', function () {
const tpl = engine.parse('before{{notdefined}}after')
const opts = {
strict_variables: true
strictVariables: true
}
return expect(engine.render(tpl, ctx, opts)).to
.be.rejectedWith(/undefined variable: notdefined/)
})
it('should pass strict_variables to render by parseAndRender', function () {
it('should pass strictVariables to render by parseAndRender', function () {
const html = 'before{{notdefined}}after'
const opts = {
strict_variables: true
strictVariables: true
}
return expect(engine.parseAndRender(html, ctx, opts)).to
.be.rejectedWith(/undefined variable: notdefined/)
+7 -7
View File
@@ -6,34 +6,34 @@ describe('LiquidOptions#trimming', function () {
describe('tag trimming', function () {
it('should respect trim_tag_left', async function () {
const engine = new Liquid({ trim_tag_left: true })
const engine = new Liquid({ trim_tag_left: true } as any)
const html = await engine.parseAndRender(' \n \t{%if true%}foo{%endif%} ')
return expect(html).to.equal('foo ')
})
it('should respect trim_tag_right', async function () {
const engine = new Liquid({ trim_tag_right: true })
const engine = new Liquid({ trim_tag_right: true } as any)
const html = await engine.parseAndRender('\t{%if true%}foo{%endif%} \n')
return expect(html).to.equal('\tfoo')
})
it('should not trim value', async function () {
const engine = new Liquid({ trim_tag_left: true, trim_tag_right: true })
const engine = new Liquid({ trim_tag_left: true, trim_tag_right: true } as any)
const html = await engine.parseAndRender('{%if true%}a {{name}} b{%endif%}', ctx)
return expect(html).to.equal('a harttle b')
})
})
describe('value trimming', function () {
it('should respect trim_output_left', async function () {
const engine = new Liquid({ trim_output_left: true })
const engine = new Liquid({ trim_output_left: true } as any)
const html = await engine.parseAndRender(' \n \t{{name}} ', ctx)
return expect(html).to.equal('harttle ')
})
it('should respect trim_output_right', async function () {
const engine = new Liquid({ trim_output_right: true })
const engine = new Liquid({ trim_output_right: true } as any)
const html = await engine.parseAndRender(' \n \t{{name}} ', ctx)
return expect(html).to.equal(' \n \tharttle')
})
it('should respect not trim tag', async function () {
const engine = new Liquid({ trim_output_left: true, trim_output_right: true })
const engine = new Liquid({ trim_output_left: true, trim_output_right: true } as any)
const html = await engine.parseAndRender('\t{% if true %} aha {%endif%}\t')
return expect(html).to.equal('\t aha \t')
})
@@ -46,7 +46,7 @@ describe('LiquidOptions#trimming', function () {
return expect(html).to.equal('aharttle')
})
it('should respect to greedy:false by default', async function () {
const engine = new Liquid({ greedy: false })
const engine = new Liquid({ greedy: false } as any)
const html = await engine.parseAndRender(src, ctx)
return expect(html).to.equal('\n a \nharttle ')
})