From fa3e2d0c55124dc47b53a608e1d0fd16db26ef47 Mon Sep 17 00:00:00 2001 From: Angus McLeod Date: Thu, 30 Mar 2023 12:09:00 +0800 Subject: [PATCH] Update wizard-char-counter.js.es6 --- .../helpers/wizard-char-counter.js.es6 | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/assets/javascripts/discourse/helpers/wizard-char-counter.js.es6 b/assets/javascripts/discourse/helpers/wizard-char-counter.js.es6 index 3cf4aee1..1e194314 100644 --- a/assets/javascripts/discourse/helpers/wizard-char-counter.js.es6 +++ b/assets/javascripts/discourse/helpers/wizard-char-counter.js.es6 @@ -2,21 +2,24 @@ import { registerUnbound } from "discourse-common/lib/helpers"; import I18n from "I18n"; import Handlebars from "handlebars"; -export default registerUnbound("wizard-char-counter", function (body, maxLength) { - let bodyLength = body ? body.length : 0; - let finalString; +export default registerUnbound( + "wizard-char-counter", + function (body, maxLength) { + let bodyLength = body ? body.length : 0; + let finalString; - if (maxLength) { - let isOverMax = bodyLength > maxLength ? "true" : "false"; - finalString = `
${bodyLength} / ${I18n.t( - "wizard.x_characters", - { count: parseInt(maxLength, 10) } - )}
`; - } else { - finalString = `
${I18n.t("wizard.x_characters", { - count: parseInt(bodyLength, 10), - })}
`; + if (maxLength) { + let isOverMax = bodyLength > maxLength ? "true" : "false"; + finalString = `
${bodyLength} / ${I18n.t( + "wizard.x_characters", + { count: parseInt(maxLength, 10) } + )}
`; + } else { + finalString = `
${I18n.t("wizard.x_characters", { + count: parseInt(bodyLength, 10), + })}
`; + } + + return new Handlebars.SafeString(finalString); } - - return new Handlebars.SafeString(finalString); -}); +);