mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-18 14:00:39 -07:00
assign tag, abs filter
This commit is contained in:
+7
-1
@@ -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
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user