JSFiddle - React, Tailwind, and code Playground

HTML

<div class="foo">
    {text}
</div>

<div class="foo">
    {othertext}
</div>

JavaScript

var newText = [];
newText.text = "some <b>new</b> text";
newText.othertext = "<b>some other</b> new text";

$('div.foo').html(function(i,txt) {
    var key = txt.match(/\{([^}]+)\}/)[1];
    return newText[key];
});