diff --git a/packages/string-templates/manifest.json b/packages/string-templates/manifest.json index 5a96885383..02bd7f8a64 100644 --- a/packages/string-templates/manifest.json +++ b/packages/string-templates/manifest.json @@ -245,7 +245,7 @@ "options" ], "numArgs": 3, - "example": "{{equalsLength [1, 2, 3] 3}} -> true", + "example": "{{equalsLength '[1,2,3]' 3}} -> true", "description": "
Returns true if the the length of the given value
is equal to the given length
. Can be used as a block or inline helper.
Returns the length of the given string or array.
\n" }, "lengthEqual": { @@ -272,7 +272,7 @@ "options" ], "numArgs": 3, - "example": "{{equalsLength [1, 2, 3] 3}} -> true", + "example": "{{equalsLength '[1,2,3]' 3}} -> true", "description": "Returns true if the the length of the given value
is equal to the given length
. Can be used as a block or inline helper.
Format a date using moment.js date formatting.
\n" + "example": "{{date now \"DD-MM-YYYY\" \"America/New_York\" }} -> 21-01-2021", + "description": "Format a date using moment.js date formatting - the timezone is optional and uses the tz database.
\n" }, "duration": { "args": [ diff --git a/packages/string-templates/package.json b/packages/string-templates/package.json index d9fbf65bf0..35810a9dfb 100644 --- a/packages/string-templates/package.json +++ b/packages/string-templates/package.json @@ -20,7 +20,7 @@ "manifest": "node ./scripts/gen-collection-info.js" }, "dependencies": { - "@budibase/handlebars-helpers": "^0.11.3", + "@budibase/handlebars-helpers": "^0.11.4", "dayjs": "^1.10.4", "handlebars": "^4.7.6", "handlebars-utils": "^1.0.6", diff --git a/packages/string-templates/test/helpers.spec.js b/packages/string-templates/test/helpers.spec.js index d460708798..e43bb5fbe1 100644 --- a/packages/string-templates/test/helpers.spec.js +++ b/packages/string-templates/test/helpers.spec.js @@ -305,6 +305,17 @@ describe("Test the object/array helper", () => { const output = await processString("{{ literal ( sum ( pluck items 'price' ) ) }}", context) expect(output).toBe(50) }) + + it("should allow use of the length helper", async () => { + const array = [1, 2, 3] + const output = await processString("{{ length array }}", { array }) + expect(output).toBe("3") + }) + + it("should allow use of the length helper inline", async () => { + const output = await processString(`{{ length '[1, 2, 3]' }}`, {}) + expect(output).toBe("3") + }) }) describe("Test the literal helper", () => { diff --git a/packages/string-templates/yarn.lock b/packages/string-templates/yarn.lock index 64534884b0..0188a9ec1d 100644 --- a/packages/string-templates/yarn.lock +++ b/packages/string-templates/yarn.lock @@ -270,10 +270,10 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== -"@budibase/handlebars-helpers@^0.11.3": - version "0.11.3" - resolved "https://registry.yarnpkg.com/@budibase/handlebars-helpers/-/handlebars-helpers-0.11.3.tgz#b6e5c91b83e8906e7d7ff10ddde277a3d561016e" - integrity sha512-MS1ptZEYq8o9J3tNLM7cZ2RGSSJIer4GiMIUHtbBI3sC9UKqZebao1JYNfmZKpNjntuqhZKgjqc5GfnVIEjsYQ== +"@budibase/handlebars-helpers@^0.11.4": + version "0.11.4" + resolved "https://registry.yarnpkg.com/@budibase/handlebars-helpers/-/handlebars-helpers-0.11.4.tgz#8acfa2ee84134f7be4b2906e710fce6d25c5d000" + integrity sha512-AJNJYlJnxZmn9QJ8tBl8nrm4YxbwHP4AR0pbiVGK+EoOylkNBlUnZ/QDL1VyqM5fTkAE/Z2IZVLKrrG3kxuWLA== dependencies: arr-flatten "^1.1.0" array-sort "^0.1.4"