mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 04:10:40 -07:00
fix #59, divide numbers as it is
This commit is contained in:
@@ -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
@@ -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
@@ -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 () {
|
||||
|
||||
Reference in New Issue
Block a user