This commit is contained in:
harttle
2016-06-19 11:16:36 +08:00
parent 1bc6d9355a
commit aa1df95714
5 changed files with 36 additions and 11 deletions
+2 -2
View File
@@ -2,14 +2,14 @@
[![NPM version](https://img.shields.io/npm/v/shopify-liquid.svg?style=flat)](https://www.npmjs.org/package/shopify-liquid)
[![Build Status](https://travis-ci.org/harttle/shopify-liquid.svg?branch=master)](https://travis-ci.org/harttle/shopify-liquid)
[![Coverage Status](https://coveralls.io/repos/github/harttle/shopify-liquid/badge.svg?branch=master)](https://coveralls.io/github/harttle/shopify-liquid?branch=master)
[![Coverage Status](https://coveralls.io/repos/github/harttle/shopify-liquid/badge.svg?branch=master&ver=1.1.1)](https://coveralls.io/github/harttle/shopify-liquid?branch=master)
[![Dependency manager](https://david-dm.org/harttle/shopify-liquid.png)](https://david-dm.org/harttle/shopify-liquid)
[Liquid][shopify-liquid] implementation for Node.js.
All tags and filters listed in [Shopify Documentation][shopify-liquid]
shall be implemented.
> Shopify liquid is used by [Jekyll][jekyll] and [Github Pages][gh].
> [Shopify liquid][shopify-liquid] is used by [Jekyll][jekyll] and [Github Pages][gh].
## Operators
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "shopify-liquid",
"version": "1.1.0",
"version": "1.1.1",
"description": "A Shopify Liquid Implementation in Node.js",
"main": "index.js",
"scripts": {
-6
View File
@@ -22,12 +22,6 @@ function test(src, dst) {
}
describe('filters', function() {
it('should output object', function() {
test('{{obj}}', '{"foo":"bar"}');
});
it('should output array', function() {
test('{{arr}}', '[-2,"a"]');
});
it('should support abs', function() {
test('{{ -3 | abs }}', '3');
test('{{ arr[0] | abs }}', '2');
+31
View File
@@ -0,0 +1,31 @@
const chai = require("chai");
const expect = chai.expect;
var liquid = require('..')(),
ctx;
function test(src, dst) {
ctx = {
date: new Date(),
foo: 'bar',
arr: [-2, 'a'],
obj: {
foo: 'bar'
},
posts: [{
category: 'foo'
}, {
category: 'bar'
}]
};
expect(liquid.render(src, ctx)).to.equal(dst);
}
describe('liquid', function() {
it('should output object', function() {
test('{{obj}}', '{"foo":"bar"}');
});
it('should output array', function() {
test('{{arr}}', '[-2,"a"]');
});
});
+2 -2
View File
@@ -54,8 +54,8 @@ describe('tags', function() {
testThrow('{% if false%}yes', /tag {% if false%} not closed/);
test('{%if emptyArray%}a{%endif%}', '');
test('{% if 2==3 %}yes{%else%}no{%endif%}', 'no');
test('{% if 1==2 and one<two %}a{%endif%}', '');
test('{% if false %}yes{%else%}no{%endif%}', 'no');
test('{% if 1>=2 and one<two %}a{%endif%}', '');
test('{% if one!=two %}yes{%else%}no{%endif%}', 'yes');
test('{% if false %}1{%elsif true%}2{%else%}3{%endif%}', '2');
test('{%if false%}{%if true%}{%else%}a{%endif%}{%endif%}', '');
});