JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://unpkg.com/handlebars@latest/dist/handlebars.js"></script>
<!--
If you need a specific version:
<script src="https://unpkg.com/handlebars@4.3.0/dist/handlebars.js"></script> -->
<div id="output"></div>
<script type="template/handlebars" id="template">{{aString.trim}}</script>
JavaScript
var template;
template = Handlebars.compile(document.getElementById('template').innerHTML);
const result = template(
{ aString: " abc " },
{
allowedProtoMethods: {
trim: true
}
}
);
console.log(result, typeof result);
document.getElementById('output').innerHTML = result;