I have an issue with a string that has double quotes (") when I get it from the backend I get it like this <span class="parsed-qr-field" rel="{ "id": 123, "sign": "45tgrl:" }"></span>
and then I have to send it through an API to another machine which renders what I'm sending
So when they try to print the HTML is giving issues due to the double quotes ". Is there a way of replacing the rel attribute value in the string for this rel="{ "id": 123, "sign": "45tgrl:" }"
as when we do it manually like that it works
We can not do the replaces statically as the rel values changes per every request
I have already tried to do things like:
_this._page += Template.TemplateHTML.replace(/"/g, '\\"')
Or
var doc = new DOMParser().parseFromString(Template.TemplateHTML, "text/html");
doc.querySelector('span[rel]').rel = doc.querySelector('span[rel]').rel.replace(/"/g, '"');
Via Active questions tagged javascript - Stack Overflow https://ift.tt/w71lyAH
Comments
Post a Comment