diff --git a/demo/nodejs/index.js b/demo/nodejs/index.js index 13e1acfcc..321eefb07 100644 --- a/demo/nodejs/index.js +++ b/demo/nodejs/index.js @@ -1,5 +1,4 @@ -// const Liquid = require('../..') -const Liquid = require('../../dist/liquid.common.js') +const Liquid = require('../..') const engine = new Liquid({ root: __dirname, diff --git a/src/util/underscore.js b/src/util/underscore.js index 3857e3219..e6b1fe8b5 100644 --- a/src/util/underscore.js +++ b/src/util/underscore.js @@ -19,8 +19,8 @@ export function stringify (value) { if (typeof value.toLiquid === 'function') { return stringify(value.toLiquid()) } - if (isString(value)) { - return value + if (isString(value) || value instanceof RegExp || value instanceof Date) { + return value.toString() } const cache = [] diff --git a/test/unit/util/underscore.js b/test/unit/util/underscore.js index 32657d435..2a006234d 100644 --- a/test/unit/util/underscore.js +++ b/test/unit/util/underscore.js @@ -51,6 +51,11 @@ describe('util/underscore', function () { it('should return "undefined" for undefined', function () { expect(_.stringify(undefined)).to.equal('undefined') }) + it('should return locale string for date', function () { + const date = new Date('2018-10-01T14:51:00.000Z') + // Mon Oct 01 2018 22:51:00 GMT+0800 (CST) + expect(_.stringify(date)).to.equal(date.toString()) + }) }) describe('.forOwn()', function () { it('should iterate all properties', function () {