// capitalize first letter(s) of words in a string hbs.registerHelper(`capitalizeFirstLetters`, function (input) { const stringifiedInput = `${input}`; console.log(`input`, stringifiedInput); const inputArray = stringifiedInput.split(` `); if (stringifiedInput.indexOf(` `) >= 0) { const capitalizedWords = inputArray.map((word) => word[0].toUpperCase() + word.slice(1)).join(` `); return capitalizedWords; } const capitalizedWord = stringifiedInput.charAt(0).toUpperCase() + stringifiedInput.slice(1); return capitalizedWord; });
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter