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-fail">
template: {{a}}{{b}}{{c}}
noEscape: <strong>true</strong>
a: 1 b: 3 c: 5
=> <strong>Result: <span class="result"></span></strong> (should be "135")
<em>/!\ Seems to be an addition of a, b, and c, when there are no characters between tokens, instead of a concatenation.</em>
</div>
<div id="output-other">
template: {{a}} {{b}} {{c}} <em>(using spaces)</em>
noEscape: <strong>true</strong>
a: 1 b: 3 c: 5
=> <strong>Result: <span class="result"></span></strong> (should be "1 3 5")
</div>
<div id="output-other-2">
template: {{a}}{{b}}{{c}}
noEscape: <strong>true</strong>
a: "1" b: "3" c: "5" <em>(integers → strings)</em>
=> <strong>Result: <span class="result"></span></strong> (should be "135")
</div>
<div id="output-success">
template: {{a}}{{b}}{{c}}
noEscape: <strong>false</strong> <em>(default)</em>
a: 1 b: 3 c: 5
=> <strong>Result: <span class="result"></span></strong> (should be "135")
</div>
<script type="template/handlebars" id="template">{{a}}{{b}}{{c}}</script>
<script type="template/handlebars" id="template-other">{{a}} {{b}} {{c}}</script>
CSS
#output-fail {
background: #f88;
border-left: 3px solid currentColor;
color: #300;
font-family: monospace;
margin-bottom: 4px;
padding: 4px 16px;
white-space: pre-wrap;
}
#output-other {
background: #ff8;
border-left: 3px solid currentColor;
color: #331900;
font-family: monospace;
margin-bottom: 4px;
padding: 4px 16px;
white-space: pre-wrap;
}
#output-other-2 {
background: #ff8;
border-left: 3px solid currentColor;
color: #331900;
font-family: monospace;
margin-bottom: 4px;
padding: 4px 16px;
white-space: pre-wrap;
}
#output-success {
background: #8f8;
border-left: 3px solid currentColor;
color: #030;
font-family: monospace;
padding: 4px 16px;
white-space: pre-wrap;
}
JavaScript
const failing = Handlebars.create()
const other = Handlebars.create()
const other2 = Handlebars.create()
const succeeding = Handlebars.create()
const templateFailing = failing.compile(document.getElementById('template').innerHTML, {
noEscape: true
})
const templateOther = other.compile(document.getElementById('template-other').innerHTML, {
noEscape: true
})
const templateOther2 = other2.compile(document.getElementById('template').innerHTML, {
noEscape: true
})
const templateSucceeding = succeeding.compile(document.getElementById('template').innerHTML, {
noEscape: false
})
document.querySelector('#output-fail .result').innerHTML = templateFailing({a: 1, b: 3, c: 5})
document.querySelector('#output-other .result').innerHTML = templateOther({a: 1, b: 3, c: 5})
document.querySelector('#output-other-2 .result').innerHTML = templateOther2({a: '1', b: '3', c: '5'})
document.querySelector('#output-success .result').innerHTML = templateSucceeding({a: 1, b: 3, c: 5})