Can anyone explain why in the following example result prints as [object Object] to the console when typeof result returns string?
I took this example from the very bottom of the handlebars documentation here: https://handlebarsjs.com/api-reference/runtime-options.html#options-to-control-prototype-access
I assume that this may have something to do with the fact that handlebars does not allow access to the toString method of the aString prototype but if the documentation is correct this should work.
var template = Handlebars.compile(document.getElementById('template').innerHTML);
var result = template({ aString: " abc " }, {
allowedProtoMethods: {
trim: true
}
});
console.log(result, typeof result);
document.getElementById('output').innerHTML = result;
<script src="https://unpkg.com/handlebars@latest/dist/handlebars.js"></script>
<div id="output"></div>
<script type="template/handlebars" id="template">{{aString.trim}}</script>