JSFiddle - React, Tailwind, and code Playground
HTML
<div id="template" style="display: none;">The quick {{Color}} {{Animal}} jumped over the lazy dog</div>
<div id="output"></div>
JavaScript
function ApplyTemplate(template, properties) {
var returnValue = "";
var templateFragments = template.split("{{");
returnValue += templateFragments[0];
for (var i = 1; i < templateFragments.length; i++) {
var fragmentSections = templateFragments[i].split("}}", 2);
returnValue += properties[fragmentSections[0]];
returnValue += fragmentSections[1];
}
return returnValue;
}
var template = $("#template").html();
var values = {
Animal: "fox",
Color: "brown"
};
var output = ApplyTemplate(template,values);
$("#output").html(output);