I have string
const message = "component="${component.name}" and id=${id}";
I have data
const data = {"id": 101, "component": { "name": "Shiv" }};
How to parse this string message, so that "${component.name}" is replaced by "Shiv" and "id" with 100,
I tried using handlebars.js but it is not compatible with my react setup
2
Answers
you can simply use regular expression to do that like so:
Have you tried using javascript template literals?
If it should be dynamic, you can have a function as follows
Should get you going on the correct path anyway