mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 04:10:40 -07:00
feat: Add support for the Jekyll sample filter (#612)
* Add support for the Jekyll sample filter See https://jekyllrb.com/docs/liquid/filters I am sorting the array randomly and then picking the first N items or all items if there is no sample limit. * Remove incorrect spaces before parens Typo and copy-paste meet
This commit is contained in:
@@ -104,6 +104,20 @@ describe('filters/array', function () {
|
||||
expect(html).toBe('abc')
|
||||
})
|
||||
})
|
||||
describe('sample', function () {
|
||||
it('should return full array sample', () => test(
|
||||
'{{ "hello,world" | split: "," | sample | size }}',
|
||||
'2'
|
||||
))
|
||||
it('should return full array sample even if excess count', () => test(
|
||||
'{{ "hello,world" | split: "," | sample: 10 | size }}',
|
||||
'2'
|
||||
))
|
||||
it('should return partial array sample', () => test(
|
||||
'{{ "hello,world" | split: "," | sample: 1 | size }}',
|
||||
'1'
|
||||
))
|
||||
})
|
||||
describe('size', function () {
|
||||
it('should return string length', () => test(
|
||||
'{{ "Ground control to Major Tom." | size }}',
|
||||
|
||||
Reference in New Issue
Block a user