liquid instance

This commit is contained in:
harttle
2016-06-15 02:04:30 +08:00
parent d29558035c
commit 51b2406187
11 changed files with 178 additions and 124 deletions
+1 -1
View File
@@ -5,7 +5,7 @@ const expect = chai.expect;
chai.use(sinonChai);
var filter = require('../filter.js');
var filter = require('../filter.js')();
var context = require('../context.js');
describe('filter', function() {
+16
View File
@@ -0,0 +1,16 @@
const chai = require("chai");
const expect = chai.expect;
var liquid = require('..')();
describe('filters', function() {
var ctx = {
foo: 'bar',
arr: [-2, 'a']
};
it('should support abs', function() {
expect(liquid.render('{{ -3 | abs }}', ctx)).to.equal('3');
expect(liquid.render('{{ arr[0] | abs }}', ctx)).to.equal('2');
});
});
+2 -2
View File
@@ -14,7 +14,7 @@ describe('identifier', function() {
it('should test number literal', function() {
identifier.isLiteral('2.3').should.equal(true);
identifier.isLiteral('.3').should.equal(true);
identifier.isLiteral('3.').should.equal(true);
identifier.isLiteral('-3.').should.equal(true);
identifier.isLiteral('23').should.equal(true);
});
@@ -58,7 +58,7 @@ describe('identifier', function() {
it('should parse number literal', function() {
identifier.parseLiteral('2.3').should.equal(2.3);
identifier.parseLiteral('.32').should.equal(0.32);
identifier.parseLiteral('23.').should.equal(23);
identifier.parseLiteral('-23.').should.equal(-23);
identifier.parseLiteral('23').should.equal(23);
});
+3 -3
View File
@@ -5,10 +5,10 @@ const expect = chai.expect;
chai.use(sinonChai);
var tag = require('../tag.js');
var tag = require('../tag.js')();
var context = require('../context.js');
var filter = require('../filter');
var render = require('../render.js');
var filter = require('../filter')();
var render = require('../render.js')(filter, tag);
describe('render', function() {
var ctx, htmlToken, tagToken, filterToken;
+1 -1
View File
@@ -4,7 +4,7 @@ var sinon = require("sinon");
var expect = chai.expect;
chai.use(sinonChai);
var tag = require('../tag.js');
var tag = require('../tag.js')();
var context = require('../context.js');
describe('tag', function() {