fix #59, divide numbers as it is

This commit is contained in:
Jun Yang
2018-05-12 22:58:43 +08:00
parent 220b705b73
commit 61f146432d
3 changed files with 4 additions and 4 deletions
+1 -1
View File
@@ -24,7 +24,7 @@ Though being compatible with [Ruby Liquid](https://github.com/shopify/liquid) is
* Dynamic file locating (enabled by default), which means layout/partial name can be an variable in liquidjs. See [#51](https://github.com/harttle/liquidjs/issues/51).
* Truthy and Falsy. All values except `undefined`, `null`, `false` are truthy, whereas in Ruby Liquid all except `nil` and `false` are truthy. See [#26](https://github.com/harttle/liquidjs/pull/26).
* Number Rendering. Since JavaScript do not distinguish `float` and `integer`, we cannot either convert between them nor render regarding their type. See [#59](https://github.com/harttle/liquidjs/issues/59).
* Number Rendering. Since JavaScript do not distinguish `float` and `integer`, we cannot either convert between them nor render regarding to their type. See [#59](https://github.com/harttle/liquidjs/issues/59).
## TOC
+1 -1
View File
@@ -33,7 +33,7 @@ var filters = {
return isValidDate(date) ? strftime(date, arg) : v
},
'default': (v, arg) => isTruthy(v) ? v : arg,
'divided_by': (v, arg) => Math.floor(v / arg),
'divided_by': (v, arg) => v / arg,
'downcase': v => v.toLowerCase(),
'escape': escape,
+2 -2
View File
@@ -110,8 +110,8 @@ describe('filters', function () {
describe('divided_by', function () {
it('should return 2 for 4,2', () => test('{{4 | divided_by: 2}}', '2'))
it('should return 4 for 16,4', () => test('{{16 | divided_by: 4}}', '4'))
it('should return 1 for 5,3', () => test('{{5 | divided_by: 3}}', '1'))
it('should convert string to number', () => test('{{"5" | divided_by: "3"}}', '1'))
it('should return 1 for 5,3', () => test('{{5 | divided_by: 3}}', (5 / 3).toString()))
it('should convert string to number', () => test('{{"6" | divided_by: "3"}}', '2'))
})
describe('downcase', function () {