feature: greedy trim disabled by default, working on #19

This commit is contained in:
harttle
2017-01-31 00:07:46 +08:00
parent af284daf34
commit 5ecca1b761
4 changed files with 53 additions and 29 deletions
+11 -4
View File
@@ -179,16 +179,23 @@ describe('liquid', function() {
engine = Liquid({
trim_left: true
});
return engine.parseAndRender('\n \t{{"foo"}} ')
.should.eventually.equal('foo ');
return engine.parseAndRender(' \n \t{{"foo"}} ')
.should.eventually.equal(' foo ');
});
it('should trim_right for tags when trim_right=true', function() {
engine = Liquid({
trim_right: true
});
return engine.parseAndRender('\t{{"foo"}} ')
return engine.parseAndRender('\t{{"foo"}} \n')
.should.eventually.equal('\tfoo');
});
it('should trim all blanks before and after when greedy=true', function() {
engine = Liquid({
greedy: true
});
return engine.parseAndRender('\t{{-"foo"-}} \n \n')
.should.eventually.equal('foo');
});
it('should support trim using markup', function() {
engine = Liquid();
var src = [
@@ -199,7 +206,7 @@ describe('liquid', function() {
' Hello there!',
'{%- endif -%}\n',
].join('\n');
var dst = 'Wow, John G. Chalmers-Smith, you have a long name!';
var dst = ' Wow, John G. Chalmers-Smith, you have a long name!';
return engine.parseAndRender(src).should.eventually.equal(dst);
});
it('should not trim when not specified', function() {