Skip to content

Commit c8c6dd8

Browse files
robinbijlaniharttle
authored andcommitted
Fix: Stringify append and prepend values
1 parent 49c45a4 commit c8c6dd8

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/builtin/filters/string.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
import { stringify } from '../../util/underscore'
77

88
export default {
9-
'append': (v: string, arg: string) => stringify(v) + arg,
10-
'prepend': (v: string, arg: string) => arg + stringify(v),
9+
'append': (v: string, arg: string) => stringify(v) + stringify(arg),
10+
'prepend': (v: string, arg: string) => stringify(arg) + stringify(v),
1111
'capitalize': capitalize,
1212
'lstrip': (v: string) => stringify(v).replace(/^\s+/, ''),
1313
'downcase': (v: string) => stringify(v).toLowerCase(),

test/integration/builtin/filters/string.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,16 @@ describe('filters/string', function () {
1010
describe('append', function () {
1111
it('should return "-3abc" for -3, "abc"',
1212
() => test('{{ -3 | append: "abc" }}', '-3abc'))
13-
it('should return "abar" for "a",foo', () => test('{{ "a" | append: foo }}', 'abar'))
13+
it('should return "abar" for "a", foo', () => test('{{ "a" | append: foo }}', 'abar'))
14+
it('should return "abc" for "abc", undefined', () => test('{{ "abc" | append: undefinedVar }}', 'abc'))
15+
it('should return "abcfalse" for "abc", false', () => test('{{ "abc" | append: false }}', 'abcfalse'))
16+
})
17+
describe('prepend', function () {
18+
it('should return "-3abc" for -3, "abc"',
19+
() => test('{{ -3 | prepend: "abc" }}', 'abc-3'))
20+
it('should return "abar" for "a", foo', () => test('{{ "a" | prepend: foo }}', 'bara'))
21+
it('should return "abc" for "abc", undefined', () => test('{{ "abc" | prepend: undefinedVar }}', 'abc'))
22+
it('should return "falseabc" for "abc", false', () => test('{{ "abc" | prepend: false }}', 'falseabc'))
1423
})
1524
describe('capitalize', function () {
1625
it('should capitalize first', async () => {

0 commit comments

Comments
 (0)