mirror of
https://github.com/zhigang1992/react-native-bottom-sheet.git
synced 2026-01-12 17:42:17 +08:00
38 lines
1.0 KiB
JavaScript
38 lines
1.0 KiB
JavaScript
module.exports = function (Handlebars) {
|
|
Handlebars.registerHelper('custom', function (context, extra, options) {
|
|
if ((!context || context.length === 0) && (!extra || extra.length === 0)) {
|
|
return '';
|
|
}
|
|
|
|
const list = [...context, ...extra]
|
|
.filter(item => {
|
|
const commit = item.commit || item;
|
|
if (options.hash.exclude) {
|
|
const pattern = new RegExp(options.hash.exclude, 'm');
|
|
if (pattern.test(commit.message)) {
|
|
return false;
|
|
}
|
|
}
|
|
if (options.hash.message) {
|
|
const pattern = new RegExp(options.hash.message, 'm');
|
|
return pattern.test(commit.message);
|
|
}
|
|
if (options.hash.subject) {
|
|
const pattern = new RegExp(options.hash.subject);
|
|
return pattern.test(commit.subject);
|
|
}
|
|
return true;
|
|
})
|
|
.map(item => options.fn(item))
|
|
.join('');
|
|
|
|
if (!list) {
|
|
return '';
|
|
}
|
|
|
|
return options.hash.heading
|
|
? `${options.hash.heading}\n\n${list}`
|
|
: `${list}`;
|
|
});
|
|
};
|