Fix regexMatch and regexReplace handlebars helper functions (#1958)

This commit is contained in:
toasted-nutbread 2021-09-26 12:15:00 -04:00 committed by GitHub
parent 14b2a9be87
commit 076170cc38
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -214,7 +214,7 @@ class AnkiTemplateRenderer {
// e.g. "i" for case-insensitive, "g" for replace all
const argCount = args.length - 1;
const options = args[argCount];
let value = options.fn(context);
let value = typeof options.fn === 'function' ? options.fn(context) : '';
if (argCount > 3) {
value = `${args.slice(3).join('')}${value}`;
}
@ -238,7 +238,7 @@ class AnkiTemplateRenderer {
// e.g. "i" for case-insensitive, "g" for match all
const argCount = args.length - 1;
const options = args[argCount];
let value = options.fn(context);
let value = typeof options.fn === 'function' ? options.fn(context) : '';
if (argCount > 2) {
value = `${args.slice(2).join('')}${value}`;
}