Fix error when using a note template and checking if array is not empty

This commit is contained in:
Martynas Bagdonas 2022-04-23 14:42:07 +07:00
parent d9463daa66
commit b8d427790c
2 changed files with 2 additions and 2 deletions

View file

@ -2240,7 +2240,7 @@ Zotero.Utilities.Internal = {
typeof vars[args[0]] === 'function'
// If function returns a value (only string is supported)
// Note: To keep things simple, this doesn't support function attributes
? !!vars[args[0]]()
? !!vars[args[0]]({})
// If string variable exists
: !!vars[args[0]]
)

View file

@ -533,7 +533,7 @@ describe("Zotero.Utilities.Internal", function () {
ar1: [],
ar2: [1, 2]
};
var template = `{{ v1}}{{v2 a1= 1 a2 =' 2' a3 = "3 "}}{{v3}}{{v4}}{{if ar1}}ar1{{endif}}{{if ar2}}{{ar2}}{{endif}}{{if v5}}yes{{endif}}{{if v3}}no{{endif}}`;
var template = `{{ v1}}{{v2 a1= 1 a2 =' 2' a3 = "3 "}}{{v3}}{{v4}}{{if ar1}}ar1{{endif}}{{if ar2}}{{ar2}}{{endif}}{{if v5}}yes{{endif}}{{if v3}}no{{endif}}{{if v2}}no{{endif}}`;
var html = Zotero.Utilities.Internal.generateHTMLFromTemplate(template, vars);
assert.equal(html, '11 23 1,2yes');
});