mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 04:10:40 -07:00
feat: add remove_last filter
This commit is contained in:
@@ -202,13 +202,23 @@ describe('filters/string', function () {
|
||||
return test('{{ "1 2 3 4 5 6 7 8 9 a b c d e f" | truncatewords }}', '1 2 3 4 5 6 7 8 9 a b c d e f...')
|
||||
})
|
||||
})
|
||||
describe('remove_last', function () {
|
||||
it('should remove the last occurrence of substring', function () {
|
||||
return test('{{ "I strained to see the train through the rain" | remove_last: "rain" }}',
|
||||
'I strained to see the train through the ')
|
||||
})
|
||||
it('should handle substring not found', function () {
|
||||
return test('{{ "I strained to see the train through the rain" | remove_last: "no such thing" }}',
|
||||
'I strained to see the train through the rain')
|
||||
})
|
||||
})
|
||||
describe('replace_last', function () {
|
||||
it('should replace the last occurrence of substring', function () {
|
||||
return test('{{ "Take my protein pills and put my helmet on" | replace_last: "my", "your" }}',
|
||||
'Take my protein pills and put your helmet on')
|
||||
})
|
||||
it('should handle substring not found', function () {
|
||||
return test('{{ "Take my protein pills and put my helmet on" | replace_last: "nosuchthing", "your" }}',
|
||||
return test('{{ "Take my protein pills and put my helmet on" | replace_last: "no such thing", "your" }}',
|
||||
'Take my protein pills and put my helmet on')
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user