mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-17 05:10:40 -07:00
Fix: Stringify append and prepend values
This commit is contained in:
@@ -6,8 +6,8 @@
|
||||
import { stringify } from '../../util/underscore'
|
||||
|
||||
export default {
|
||||
'append': (v: string, arg: string) => stringify(v) + arg,
|
||||
'prepend': (v: string, arg: string) => arg + stringify(v),
|
||||
'append': (v: string, arg: string) => stringify(v) + stringify(arg),
|
||||
'prepend': (v: string, arg: string) => stringify(arg) + stringify(v),
|
||||
'capitalize': capitalize,
|
||||
'lstrip': (v: string) => stringify(v).replace(/^\s+/, ''),
|
||||
'downcase': (v: string) => stringify(v).toLowerCase(),
|
||||
|
||||
@@ -10,7 +10,16 @@ describe('filters/string', function () {
|
||||
describe('append', function () {
|
||||
it('should return "-3abc" for -3, "abc"',
|
||||
() => test('{{ -3 | append: "abc" }}', '-3abc'))
|
||||
it('should return "abar" for "a",foo', () => test('{{ "a" | append: foo }}', 'abar'))
|
||||
it('should return "abar" for "a", foo', () => test('{{ "a" | append: foo }}', 'abar'))
|
||||
it('should return "abc" for "abc", undefined', () => test('{{ "abc" | append: undefinedVar }}', 'abc'))
|
||||
it('should return "abcfalse" for "abc", false', () => test('{{ "abc" | append: false }}', 'abcfalse'))
|
||||
})
|
||||
describe('prepend', function () {
|
||||
it('should return "-3abc" for -3, "abc"',
|
||||
() => test('{{ -3 | prepend: "abc" }}', 'abc-3'))
|
||||
it('should return "abar" for "a", foo', () => test('{{ "a" | prepend: foo }}', 'bara'))
|
||||
it('should return "abc" for "abc", undefined', () => test('{{ "abc" | prepend: undefinedVar }}', 'abc'))
|
||||
it('should return "falseabc" for "abc", false', () => test('{{ "abc" | prepend: false }}', 'falseabc'))
|
||||
})
|
||||
describe('capitalize', function () {
|
||||
it('should capitalize first', async () => {
|
||||
|
||||
Reference in New Issue
Block a user