Let we have the user input stored in a variable t,
let t = '[1,2,3,4].map(e=>"<div>{{ e }}</div>")';.
Whereby a user is forced to write this syntax to execute, so on
t = t.replace(/\{\{(.*)?\}\}/g,"$1");.
We will be getting new t as,
t = '[1,2,3,4].map(e=>"<div> e </div>")'.
So now the question arises is how to pass this string to eval so that it considers it as an argument variable not the String. So, the output becomes,
<div>1</div><div>2</div><div>3</div><div>4</div>.
eval()for anything. You're opening yourself up to security risks. See the MDN docs developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/…!