From b8d427790c24ae8d091537b71a6d6698da06ae7a Mon Sep 17 00:00:00 2001 From: Martynas Bagdonas Date: Sat, 23 Apr 2022 14:42:07 +0700 Subject: [PATCH] Fix error when using a note template and checking if array is not empty --- chrome/content/zotero/xpcom/utilities_internal.js | 2 +- test/tests/utilities_internalTest.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/xpcom/utilities_internal.js b/chrome/content/zotero/xpcom/utilities_internal.js index 9abbe61a2f..f4e077230a 100644 --- a/chrome/content/zotero/xpcom/utilities_internal.js +++ b/chrome/content/zotero/xpcom/utilities_internal.js @@ -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]] ) diff --git a/test/tests/utilities_internalTest.js b/test/tests/utilities_internalTest.js index d6e44e92ed..2e27ec6470 100644 --- a/test/tests/utilities_internalTest.js +++ b/test/tests/utilities_internalTest.js @@ -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'); });