perf: parse filenames in parse() insteadof render()

This commit is contained in:
harttle
2021-09-30 22:15:09 +08:00
committed by Jun Yang
parent 24f5346084
commit 8273c17dab
13 changed files with 80 additions and 68 deletions
+1 -1
View File
@@ -44,7 +44,7 @@ describe('tags/include', function () {
})
return liquid.renderFile('/parent.html').catch(function (e) {
expect(e.name).to.equal('RenderError')
expect(e.message).to.match(/illegal filename "not-exist"/)
expect(e.message).to.match(/illegal filename "undefined"/)
})
})
+1 -1
View File
@@ -38,7 +38,7 @@ describe('tags/layout', function () {
})
return liquid.renderFile('/parent.html').catch(function (e) {
expect(e.name).to.equal('RenderError')
expect(e.message).to.contain('file "foo"("undefined") not available')
expect(e.message).to.contain('illegal filename "undefined"')
})
})
it('should handle layout none', async function () {
+1 -1
View File
@@ -44,7 +44,7 @@ describe('tags/render', function () {
})
return liquid.renderFile('/parent.html').catch(function (e) {
expect(e.name).to.equal('RenderError')
expect(e.message).to.match(/illegal filename "not-exist":"undefined"/)
expect(e.message).to.match(/illegal filename "undefined"/)
})
})
+1 -2
View File
@@ -269,9 +269,8 @@ describe('error', function () {
.to.throw(RenderError, /intended render error/)
})
it('should contain original error info for {% include %}', function () {
const origin = ['1st', '2nd', '3rd', 'X{%throwingTag%} Y', '5th', '6th', '7th']
mock({
'/throwing-tag.html': origin.join('\n')
'/throwing-tag.html': ['1st', '2nd', '3rd', 'X{%throwingTag%} Y', '5th', '6th', '7th'].join('\n')
})
const html = '{%include "throwing-tag.html"%}'
const message = [
+3 -3
View File
@@ -8,14 +8,14 @@ chai.use(sinonChai)
const expect = chai.expect
describe('PropertyAccessToken', function () {
describe('getVariableAsText', function () {
describe('#propertyName', function () {
it('should return correct value for IdentifierToken', function () {
const token = new PropertyAccessToken(new IdentifierToken('foo', 0, 3), [], 3)
expect(token.getVariableAsText()).to.equal('foo')
expect(token.propertyName).to.equal('foo')
})
it('should return correct value for QuotedToken', function () {
const token = new PropertyAccessToken(new QuotedToken('"foo bar"', 0, 9), [], 9)
expect(token.getVariableAsText()).to.equal('foo bar')
expect(token.propertyName).to.equal('foo bar')
})
})
})