feat: compact filter

This commit is contained in:
harttle
2021-02-04 22:47:34 +08:00
parent ec4a711e00
commit f42c217fc0
3 changed files with 14 additions and 4 deletions
@@ -50,6 +50,12 @@ describe('filters/array', function () {
return test(tpl, { arr: [a, b, c] }, 'Alice Bob Carol')
})
})
describe('compact', () => {
it('should compact array', function () {
const posts = [{ category: 'foo' }, { category: 'bar' }, { foo: 'bar' }]
return test('{{posts | map: "category" | compact}}', { posts }, 'foo,bar')
})
})
describe('reverse', function () {
it('should support reverse', () => test(
'{{ "Ground control to Major Tom." | split: "" | reverse | join: "" }}',