Closed paulinemss closed 2 years ago
Hi @paulinemss!
This is a vhtml thing fwiw, not HTM. That said, you're close to the right solution! html() doesn't support bypassing sanitization of nested calls (I don't recall the reason). It does support the dangerouslySetInnerHTML
prop similar to React though, which does what you're looking for:
const frag = "<p>We <3 <em>htm</em></p>";
const rendered = html`<div dangerouslySetInnerHTML=${{ __html: frag }}></div>`;
Thanks a lot @developit!
Hi,
An issue came up with HTML content that we receive from the server. We want to insert it into
htm
without escaping it. According to #137, we should be able to do as follows:However, this doesn't work with HTML special characters - see example below (and in CodeSandbox). It looks like
html([])
is still escaping&
to&
, which breaks other special chars.Could this be a bug? Or is above not the intended use case for inserting literal HTML? Is this perhaps not supported at all?
As an example use case, we might be getting highlighted search results (
I <3 <em>htm</em>
) from the trusted server, which we want to insert into ahtm
template without escaping.See example in CodeSandbox