JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://getfirebug.com/firebug-lite.js"></script>
JavaScript
var replacer = function(tpl, data) {
return tpl.replace(/\$\(([^\)]+)?\)/g, function($1, $2) { return data[$2]; });
}
var html = '<!DOCTYPE html>\
<html lang="en">\
<head>\
<meta charset="UTF-8">\
<title>Document $(title)</title>\
</head>\
<body>\
<h1>Test file, $(text)</h1>\
</body>\
</html>';
var result = replacer(html, { "title" : "my title", "text" : "text is this" });
alert(result);