mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-29 15:15:23 -07:00
fix: number convertion for plus filter, closes #18
This commit is contained in:
+1
-1
@@ -40,7 +40,7 @@ var filters = {
|
|||||||
'minus': bindFixed((v, arg) => v - arg),
|
'minus': bindFixed((v, arg) => v - arg),
|
||||||
'modulo': bindFixed((v, arg) => v % arg),
|
'modulo': bindFixed((v, arg) => v % arg),
|
||||||
'newline_to_br': v => v.replace(/\n/g, '<br />'),
|
'newline_to_br': v => v.replace(/\n/g, '<br />'),
|
||||||
'plus': bindFixed((v, arg) => v + arg),
|
'plus': bindFixed((v, arg) => Number(v) + Number(arg)),
|
||||||
'prepend': (v, arg) => arg + v,
|
'prepend': (v, arg) => arg + v,
|
||||||
'remove': (v, arg) => v.split(arg).join(''),
|
'remove': (v, arg) => v.split(arg).join(''),
|
||||||
'remove_first': (v, l) => v.replace(l, ''),
|
'remove_first': (v, l) => v.replace(l, ''),
|
||||||
|
|||||||
@@ -133,6 +133,7 @@ describe('filters', function() {
|
|||||||
it('should return "12" for 16,4', () => test('{{ 16 | minus: 4 }}', '12'));
|
it('should return "12" for 16,4', () => test('{{ 16 | minus: 4 }}', '12'));
|
||||||
it('should return "171.357" for 183.357,12',
|
it('should return "171.357" for 183.357,12',
|
||||||
() => test('{{ 183.357 | minus: 12 }}', '171.357'));
|
() => test('{{ 183.357 | minus: 12 }}', '171.357'));
|
||||||
|
it('should convert string to number', () => test('{{ "4" | minus: 1 }}', '3'));
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('modulo', function() {
|
describe('modulo', function() {
|
||||||
@@ -159,6 +160,7 @@ describe('filters', function() {
|
|||||||
it('should return "20" for 16,4', () => test('{{ 16 | plus: 4 }}', '20'));
|
it('should return "20" for 16,4', () => test('{{ 16 | plus: 4 }}', '20'));
|
||||||
it('should return "195.357" for 183.357,12',
|
it('should return "195.357" for 183.357,12',
|
||||||
() => test('{{ 183.357 | plus: 12 }}', '195.357'));
|
() => test('{{ 183.357 | plus: 12 }}', '195.357'));
|
||||||
|
it('should convert string to number', () => test('{{ "4" | plus: 2 }}', '6'));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should support prepend', function() {
|
it('should support prepend', function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user