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.
16 lines
375 B
JavaScript
16 lines
375 B
JavaScript
7 years ago
|
/*
|
||
|
Render elements of an array joined by a separator
|
||
|
Usage:
|
||
|
{{#join list ","}}
|
||
|
{{.}}
|
||
|
{{/join}}
|
||
|
*/
|
||
|
module.exports = function (array, separator, options) {
|
||
|
const data = require('handlebars').createFrame({})
|
||
|
const blocks = array.map((item, index) => {
|
||
|
data.index = index
|
||
|
return options.fn(item, {data: data})
|
||
|
})
|
||
|
return blocks.join(separator)
|
||
|
}
|