Helpers functions bug fixes (#11003)

* Helpers functions bug fixes

* Corrected multiply example

* Removing test for times.

---------

Co-authored-by: mike12345567 <me@michaeldrury.co.uk>
This commit is contained in:
Conor Webb 2023-07-03 12:07:45 +01:00 committed by GitHub
parent bc47f5b0b2
commit 3aad1e8ca3
4 changed files with 8 additions and 35 deletions

View File

@ -75,7 +75,7 @@
], ],
"numArgs": 2, "numArgs": 2,
"example": "{{ multiply 10 5 }} -> 50", "example": "{{ multiply 10 5 }} -> 50",
"description": "<p>Return the product of <code>a</code> times <code>b</code>.</p>\n" "description": "<p>Multiply number <code>a</code> by number <code>b</code>.</p>\n"
}, },
"plus": { "plus": {
"args": [ "args": [
@ -128,15 +128,6 @@
"numArgs": 1, "numArgs": 1,
"example": "{{ sum [1, 2, 3] }} -> 6", "example": "{{ sum [1, 2, 3] }} -> 6",
"description": "<p>Returns the sum of all numbers in the given array.</p>\n" "description": "<p>Returns the sum of all numbers in the given array.</p>\n"
},
"times": {
"args": [
"a",
"b"
],
"numArgs": 2,
"example": "{{ times 10 5 }} -> 50",
"description": "<p>Multiply number <code>a</code> by number <code>b</code>.</p>\n"
} }
}, },
"array": { "array": {
@ -497,19 +488,9 @@
"str" "str"
], ],
"numArgs": 1, "numArgs": 1,
"example": "{{ escape 'https://myurl?Hello%20There' }} -> https://myurl?Hello+There", "example": "{{ decodeURI 'https://myurl?Hello%20There' }} -> https://myurl?=Hello There",
"description": "<p>Decode a Uniform Resource Identifier (URI) component.</p>\n" "description": "<p>Decode a Uniform Resource Identifier (URI) component.</p>\n"
}, },
"url_encode": {
"args": [],
"numArgs": 0,
"description": "<p>Alias for <a href=\"#encodeuri\">encodeURI</a>.</p>\n"
},
"url_decode": {
"args": [],
"numArgs": 0,
"description": "<p>Alias for <a href=\"#decodeuri\">decodeURI</a>.</p>\n"
},
"urlResolve": { "urlResolve": {
"args": [ "args": [
"base", "base",
@ -625,7 +606,7 @@
"length" "length"
], ],
"numArgs": 2, "numArgs": 2,
"example": "{{ellipsis 'foo bar baz' 7}} -> foo bar…", "example": "{{ellipsis 'foo bar baz', 7}} -> foo bar…",
"description": "<p>Truncates a string to the specified <code>length</code>, and appends it with an elipsis, <code>…</code>.</p>\n" "description": "<p>Truncates a string to the specified <code>length</code>, and appends it with an elipsis, <code>…</code>.</p>\n"
}, },
"hyphenate": { "hyphenate": {
@ -1219,4 +1200,4 @@
"description": "<p>Produce a humanized duration left/until given an amount of time and the type of time measurement.</p>\n" "description": "<p>Produce a humanized duration left/until given an amount of time and the type of time measurement.</p>\n"
} }
} }
} }

View File

@ -25,7 +25,7 @@
"manifest": "node ./scripts/gen-collection-info.js" "manifest": "node ./scripts/gen-collection-info.js"
}, },
"dependencies": { "dependencies": {
"@budibase/handlebars-helpers": "^0.11.8", "@budibase/handlebars-helpers": "^0.11.9",
"dayjs": "^1.10.4", "dayjs": "^1.10.4",
"handlebars": "^4.7.6", "handlebars": "^4.7.6",
"handlebars-utils": "^1.0.6", "handlebars-utils": "^1.0.6",

View File

@ -9,8 +9,8 @@ const marked = require("marked")
* full list of supported helpers can be found here: * full list of supported helpers can be found here:
* https://github.com/budibase/handlebars-helpers * https://github.com/budibase/handlebars-helpers
*/ */
const { join } = require("path")
const DIRECTORY = fs.existsSync("node_modules") ? "." : ".." const DIRECTORY = join(__dirname, "..", "..", "..")
const COLLECTIONS = [ const COLLECTIONS = [
"math", "math",
"array", "array",
@ -20,7 +20,7 @@ const COLLECTIONS = [
"comparison", "comparison",
"object", "object",
] ]
const FILENAME = `${DIRECTORY}/manifest.json` const FILENAME = join(__dirname, "..", "manifest.json")
const outputJSON = {} const outputJSON = {}
const ADDED_HELPERS = { const ADDED_HELPERS = {
date: { date: {

View File

@ -48,14 +48,6 @@ describe("test the math helpers", () => {
}) })
expect(parseInt(output)).toBe(2) 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", () => { describe("test the array helpers", () => {