From 78a427a92c9817e51c25d69f3d830b23ac86d571 Mon Sep 17 00:00:00 2001 From: metal Date: Fri, 27 Aug 2021 13:37:33 +0000 Subject: [PATCH] add strlen and rounding --- backend/src/templateFormatter.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/backend/src/templateFormatter.ts b/backend/src/templateFormatter.ts index 7b61af1e..4f9c1f81 100644 --- a/backend/src/templateFormatter.ts +++ b/backend/src/templateFormatter.ts @@ -388,6 +388,10 @@ const baseValues = { ucfirst(arg) { return baseValues.upperFirst(arg); }, + strlen(arg) { + if (typeof arg !== "string") return arg; + return arg.length; + }, rand(from, to, seed = null) { if (isNaN(from)) return 0; @@ -406,6 +410,10 @@ const baseValues = { return Math.round(randValue * (to - from) + from); }, + round(arg, decimals = 0) { + if (isNaN(arg)) return 0; + return decimals === 0 ? Math.round(arg) : arg.toFixed(decimals); + }, add(...args) { return args.reduce((result, arg) => { if (isNaN(arg)) return result;