mirror of https://github.com/thumbsup/thumbsup
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
390 B
JavaScript
19 lines
390 B
JavaScript
/*
|
|
Render the first X items in an array
|
|
Usage:
|
|
{{#slice items count=3}}
|
|
{{name}}
|
|
{{/slice}}
|
|
*/
|
|
module.exports = (context, block) => {
|
|
let ret = ''
|
|
let count = parseInt(block.hash.count)
|
|
if (isNaN(count)) count = 1
|
|
let i = 0
|
|
const j = (count < context.length) ? count : context.length
|
|
for (i, j; i < j; i++) {
|
|
ret += block.fn(context[i])
|
|
}
|
|
return ret
|
|
}
|