mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-17 05:10:40 -07:00
fix #61: static filename not parsed for subdirectories
This commit is contained in:
+34
-12
@@ -24,13 +24,13 @@ describe('tags/include', function () {
|
||||
.eventually.equal('barfoobar')
|
||||
})
|
||||
|
||||
it('should throw when illegal', function () {
|
||||
it('should throw when not exist', function () {
|
||||
mock({
|
||||
'/illegal.html': '{%include%}'
|
||||
'/parent.html': '{%include not-exist%}'
|
||||
})
|
||||
return liquid.renderFile('/illegal.html').catch(function (e) {
|
||||
expect(e.name).to.equal('ParseError')
|
||||
expect(e.message).to.match(/illegal token {%include%}/)
|
||||
return liquid.renderFile('/parent.html').catch(function (e) {
|
||||
expect(e.name).to.equal('RenderError')
|
||||
expect(e.message).to.match(/cannot include with empty filename/)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -89,13 +89,35 @@ describe('tags/include', function () {
|
||||
.eventually.equal('This is a person <p>Joe Shmoe<br/>City: Dallas</p>')
|
||||
})
|
||||
|
||||
it('should support static filename', function () {
|
||||
var staticLiquid = new Liquid({dynamicPartials: false, root: '/'})
|
||||
mock({
|
||||
'/with.html': 'X{% include color.html shape: "rect" %}Y',
|
||||
'/color.html': 'shape:{{shape}}'
|
||||
describe('static partial', function () {
|
||||
it('should support filename with extention', function () {
|
||||
mock({
|
||||
'/parent.html': 'X{% include child.html color:"red" %}Y',
|
||||
'/child.html': 'child with {{color}}'
|
||||
})
|
||||
var staticLiquid = new Liquid({dynamicPartials: false, root: '/'})
|
||||
return expect(staticLiquid.renderFile('parent.html')).to
|
||||
.eventually.equal('Xchild with redY')
|
||||
})
|
||||
|
||||
it('should support parent paths', function () {
|
||||
mock({
|
||||
'/parent.html': 'X{% include bar/./../foo/child.html %}Y',
|
||||
'/foo/child.html': 'child'
|
||||
})
|
||||
var staticLiquid = new Liquid({dynamicPartials: false, root: '/'})
|
||||
return expect(staticLiquid.renderFile('parent.html')).to
|
||||
.eventually.equal('XchildY')
|
||||
})
|
||||
|
||||
it('should support subpaths', function () {
|
||||
mock({
|
||||
'/parent.html': 'X{% include foo/child.html %}Y',
|
||||
'/foo/child.html': 'child'
|
||||
})
|
||||
var staticLiquid = new Liquid({dynamicPartials: false, root: '/'})
|
||||
return expect(staticLiquid.renderFile('parent.html')).to
|
||||
.eventually.equal('XchildY')
|
||||
})
|
||||
return expect(staticLiquid.renderFile('with.html')).to
|
||||
.eventually.equal('Xshape:rectY')
|
||||
})
|
||||
})
|
||||
|
||||
+30
-7
@@ -96,13 +96,36 @@ describe('tags/layout', function () {
|
||||
return expect(liquid.renderFile('/main.html')).to
|
||||
.eventually.equal('blackredA')
|
||||
})
|
||||
it('should support static filename', function () {
|
||||
mock({
|
||||
'/parent.html': '{{color}}{%block%}{%endblock%}',
|
||||
'/main.html': '{% layout parent.html color:"black"%}{%block%}A{%endblock%}'
|
||||
|
||||
describe('static partial', function () {
|
||||
it('should support filename with extention', function () {
|
||||
mock({
|
||||
'/parent.html': '{{color}}{%block%}{%endblock%}',
|
||||
'/main.html': '{% layout parent.html color:"black"%}{%block%}A{%endblock%}'
|
||||
})
|
||||
var staticLiquid = Liquid({ root: '/', dynamicPartials: false })
|
||||
return expect(staticLiquid.renderFile('/main.html')).to
|
||||
.eventually.equal('blackA')
|
||||
})
|
||||
|
||||
it('should support parent paths', function () {
|
||||
mock({
|
||||
'/foo/parent.html': '{{color}}{%block%}{%endblock%}',
|
||||
'/main.html': '{% layout bar/../foo/parent.html color:"black"%}{%block%}A{%endblock%}'
|
||||
})
|
||||
var staticLiquid = Liquid({ root: '/', dynamicPartials: false })
|
||||
return expect(staticLiquid.renderFile('/main.html')).to
|
||||
.eventually.equal('blackA')
|
||||
})
|
||||
|
||||
it('should support subpaths', function () {
|
||||
mock({
|
||||
'/foo/parent.html': '{{color}}{%block%}{%endblock%}',
|
||||
'/main.html': '{% layout foo/parent.html color:"black"%}{%block%}A{%endblock%}'
|
||||
})
|
||||
var staticLiquid = Liquid({ root: '/', dynamicPartials: false })
|
||||
return expect(staticLiquid.renderFile('/main.html')).to
|
||||
.eventually.equal('blackA')
|
||||
})
|
||||
var staticLiquid = Liquid({ root: '/', dynamicPartials: false })
|
||||
return expect(staticLiquid.renderFile('/main.html')).to
|
||||
.eventually.equal('blackA')
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user