assign tag, abs filter

This commit is contained in:
harttle
2016-06-15 03:21:35 +08:00
parent 51b2406187
commit 611882ae10
10 changed files with 176 additions and 36 deletions
+7 -1
View File
@@ -6,7 +6,7 @@ var context = require('../context.js');
describe('context', function() {
var ctx;
before(function(){
beforeEach(function(){
ctx = context.factory({
foo: 'bar',
bar: ['a', {b: [1, 2]}]
@@ -23,6 +23,11 @@ describe('context', function() {
ctx.get('foo').should.equal('bar');
});
it('should set property', function() {
ctx.set('foo', 'FOO');
ctx.get('foo').should.equal('FOO');
});
it('should get desendent property', function() {
ctx.get('bar[0]').should.equal('a');
ctx.get('bar[1].b').should.deep.equal([1, 2]);
@@ -37,6 +42,7 @@ describe('context', function() {
});
it('should pop context', function() {
ctx.push({foo: 'foo', foo1: 'foo1'});
ctx.pop();
expect(ctx.get('foo')).to.equal('bar');
expect(ctx.get('foo1')).to.equal('');
+1 -1
View File
@@ -8,7 +8,7 @@ chai.use(sinonChai);
var tag = require('../tag.js')();
var context = require('../context.js');
var filter = require('../filter')();
var render = require('../render.js')(filter, tag);
var render = require('../render.js')(filter, tag).render;
describe('render', function() {
var ctx, htmlToken, tagToken, filterToken;
+19
View File
@@ -0,0 +1,19 @@
const chai = require("chai");
const expect = chai.expect;
var liquid = require('..')();
var ctx = {
foo: 'bar',
arr: [-2, 'a']
};
describe('tags', function() {
it('should support assign', function() {
test('{% assign foo="bar"%}{{foo}}', 'bar');
});
});
function test(src, dst){
expect(liquid.render(src, ctx)).to.equal(dst);
}