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