Using single quotes to set an attribute in a template are ignored, replaced with double quote

When setting attributes, most of the time you are setting them with a double quote, like so:
<div id="something" data-foo="your data"></div>

However, I would like to use a single quote, the ’ charecter like so:
<div id="something" data-foo='{"singlequoteddata":"here"}'></div>

Right now, if a single quote is used in a template partial, it is ignored and replaced with a double quote.

The reason for wanting this is to put json data inside the data attribute, as seen on this question in the past. . In the example, it’s needed to quote strings, which requires the double quote charecter inside the string itself.

Check out safehtml.


Thank you, that does work amazing. The crazy thing with this too (above safeHTML) is the change is transperant to the client browser using inspector. It looks the same! but when you see the source code, it is correctly using a single quote.