JSFiddle - React, Tailwind, and code Playground
HTML
<div class="foo">
{text}
</div>
<div class="foo">
{othertext}
</div>
JavaScript
var newText = {
text: "some new text",
othertext: "some other new text"
}
$('div.foo').text(function(i,txt) {
var key = txt.match(/\{([^}]+)\}/)[1];
return newText[key];
});