From 3aad1e8ca3d8d4dbfccebc50af3f380c00291bda Mon Sep 17 00:00:00 2001 From: Conor Webb <126772285+ConorWebb96@users.noreply.github.com> Date: Mon, 3 Jul 2023 12:07:45 +0100 Subject: [PATCH] Helpers functions bug fixes (#11003) * Helpers functions bug fixes * Corrected multiply example * Removing test for times. --------- Co-authored-by: mike12345567 --- packages/string-templates/manifest.json | 27 +++---------------- packages/string-templates/package.json | 2 +- .../scripts/gen-collection-info.js | 6 ++--- .../string-templates/test/helpers.spec.js | 8 ------ 4 files changed, 8 insertions(+), 35 deletions(-) diff --git a/packages/string-templates/manifest.json b/packages/string-templates/manifest.json index f837f3aa75..087f1fd8ab 100644 --- a/packages/string-templates/manifest.json +++ b/packages/string-templates/manifest.json @@ -75,7 +75,7 @@ ], "numArgs": 2, "example": "{{ multiply 10 5 }} -> 50", - "description": "

Return the product of a times b.

\n" + "description": "

Multiply number a by number b.

\n" }, "plus": { "args": [ @@ -128,15 +128,6 @@ "numArgs": 1, "example": "{{ sum [1, 2, 3] }} -> 6", "description": "

Returns the sum of all numbers in the given array.

\n" - }, - "times": { - "args": [ - "a", - "b" - ], - "numArgs": 2, - "example": "{{ times 10 5 }} -> 50", - "description": "

Multiply number a by number b.

\n" } }, "array": { @@ -497,19 +488,9 @@ "str" ], "numArgs": 1, - "example": "{{ escape 'https://myurl?Hello%20There' }} -> https://myurl?Hello+There", + "example": "{{ decodeURI 'https://myurl?Hello%20There' }} -> https://myurl?=Hello There", "description": "

Decode a Uniform Resource Identifier (URI) component.

\n" }, - "url_encode": { - "args": [], - "numArgs": 0, - "description": "

Alias for encodeURI.

\n" - }, - "url_decode": { - "args": [], - "numArgs": 0, - "description": "

Alias for decodeURI.

\n" - }, "urlResolve": { "args": [ "base", @@ -625,7 +606,7 @@ "length" ], "numArgs": 2, - "example": "{{ellipsis 'foo bar baz' 7}} -> foo bar…", + "example": "{{ellipsis 'foo bar baz', 7}} -> foo bar…", "description": "

Truncates a string to the specified length, and appends it with an elipsis, .

\n" }, "hyphenate": { @@ -1219,4 +1200,4 @@ "description": "

Produce a humanized duration left/until given an amount of time and the type of time measurement.

\n" } } -} +} \ No newline at end of file diff --git a/packages/string-templates/package.json b/packages/string-templates/package.json index b1a276369f..07326d31b7 100644 --- a/packages/string-templates/package.json +++ b/packages/string-templates/package.json @@ -25,7 +25,7 @@ "manifest": "node ./scripts/gen-collection-info.js" }, "dependencies": { - "@budibase/handlebars-helpers": "^0.11.8", + "@budibase/handlebars-helpers": "^0.11.9", "dayjs": "^1.10.4", "handlebars": "^4.7.6", "handlebars-utils": "^1.0.6", diff --git a/packages/string-templates/scripts/gen-collection-info.js b/packages/string-templates/scripts/gen-collection-info.js index bfc0ec79ac..1dbb20e5cf 100644 --- a/packages/string-templates/scripts/gen-collection-info.js +++ b/packages/string-templates/scripts/gen-collection-info.js @@ -9,8 +9,8 @@ const marked = require("marked") * full list of supported helpers can be found here: * https://github.com/budibase/handlebars-helpers */ - -const DIRECTORY = fs.existsSync("node_modules") ? "." : ".." +const { join } = require("path") +const DIRECTORY = join(__dirname, "..", "..", "..") const COLLECTIONS = [ "math", "array", @@ -20,7 +20,7 @@ const COLLECTIONS = [ "comparison", "object", ] -const FILENAME = `${DIRECTORY}/manifest.json` +const FILENAME = join(__dirname, "..", "manifest.json") const outputJSON = {} const ADDED_HELPERS = { date: { diff --git a/packages/string-templates/test/helpers.spec.js b/packages/string-templates/test/helpers.spec.js index 1969410993..a587ca60dd 100644 --- a/packages/string-templates/test/helpers.spec.js +++ b/packages/string-templates/test/helpers.spec.js @@ -48,14 +48,6 @@ describe("test the math helpers", () => { }) expect(parseInt(output)).toBe(2) }) - - it("should be able to times", async () => { - const output = await processString("{{times a b}}", { - a: 5, - b: 5, - }) - expect(parseInt(output)).toBe(25) - }) }) describe("test the array helpers", () => {