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">{{nested.awesome}}</script>
JavaScript
const template = Handlebars.compile(document.getElementById('template').innerHTML)
const context = {
nested: {
awesome: function () {
return this.more;
},
more: 'Deeply awesome'
},
more: 'More awesome'
}
document.getElementById('output').innerHTML
= `handlebars: ${template(context)}<br>
javascript: ${context.nested.awesome()}`