JSFiddle - React, Tailwind, and code Playground

JavaScript

String.prototype.template = function(obj) {
    return this.replace(/\{\{([\w]+)\}\}/g, function(str, prop) {
                return val = obj[prop];
            });
};
    
alert('<div>my name is: {{last}}, {{first}}</div>'.template({first:'John', last:'Smith'}));