From a482b4abe59bb00cc5fadc388d5aadc85e65345b Mon Sep 17 00:00:00 2001 From: harttle Date: Sun, 26 Jun 2016 12:52:37 +0800 Subject: [PATCH] render undefined to '' --- README.md | 6 ++---- package.json | 2 +- src/render.js | 2 +- test/liquid.js | 3 +++ 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 4cf7b6fbd..cc972a1a9 100644 --- a/README.md +++ b/README.md @@ -102,9 +102,7 @@ Footer * It's possible to define multiple blocks. * block name is optional when there's only one block. -## Extension - -Register Filters: +## Register Filters ```javascript // Usage: {{ name | uppper }} @@ -115,7 +113,7 @@ engine.registerFilter('upper', function(v){ > See existing filter implementations: -Register Tags: +## Register Tags ```javascript // Usage: {% upper name%} diff --git a/package.json b/package.json index e28965513..4ba3fdf5e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "shopify-liquid", - "version": "1.1.7", + "version": "1.1.8", "description": "A Shopify Liquid Implementation in Node.js", "main": "index.js", "scripts": { diff --git a/src/render.js b/src/render.js index a07f1e2af..d10ba8ee5 100644 --- a/src/render.js +++ b/src/render.js @@ -21,7 +21,7 @@ var render = { break; case 'output': var val = this.evalOutput(template, scope); - html += stringify(val); + html += val === undefined ? '' : stringify(val); } }); return html; diff --git a/test/liquid.js b/test/liquid.js index 990739aa3..48163356e 100644 --- a/test/liquid.js +++ b/test/liquid.js @@ -32,6 +32,9 @@ describe('liquid', function() { it('should output array', function() { engine.parseAndRender('{{arr}}', ctx).should.equal('[-2,"a"]'); }); + it('should output undefined to empty', function() { + engine.parseAndRender('foo{{zzz}}bar', ctx).should.equal('foobar'); + }); it('should parse html', function() { (function() { engine.parse('{{obj}}');