-
Notifications
You must be signed in to change notification settings - Fork 170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
isnt rendering in htm #234
Comments
Similar issue with all Unicode HTML codes like I tried implementing the example below using the htm library instead of JSX, and it prints the code instead of the character. https://codesandbox.io/s/8w7058yp9?from-embed=&file=/src/index.js @openHawkes have you heard anything back or have you found a solution? |
@tim-lynn-clark I have not been contacted or found a solution past sort of hackily inserting whitespace in a somewhat odd place in my template instead of using |
Just a small note (in case that somebody likes it): as long as HTML entities will not be rendered properly, I'll use alternatives such as If you prefer s.th. more human-readable, you could define
This approach can also be used for decimal character codes (in case that you don't want to convert them into hexadecimal):
(the character code was taken from a previous message in this issue, it does not show any emoji on my machine...) |
HTM doesn't decode HTML Entities because doing so requires one of two things:
Since neither of those two options are viable, we just don't support HTML Entities. They're only supported in JSX because doing so made sense in a very different context (in build tools in 2014). @rozek 's solutions are what I'd recommend, or just use the character you want as a literal. If you want an emoji, paste the emoji into your editor and make sure your bundles are served with a utf-8 mime encoding - that's better than hand writing surrogate pairs 🧝♂️. |
Thank you for clarifying this! Wouldn't you like to add this constraint to the docs? This would prevent others to run into the same problem - and you could close this issue afterwards... |
When I have
in htm, it's outputting as literally
in the html.I've seen some similar questions for JSX, but it seems that, even there, the space should render.
Is HTM's not rendering it as a non-breaking space intentional?
Here's a near-simplest case reproduction. Obviously the key is
render(html`# #`, document.getElementById('root-element'));
. It comes out without a space.(Strangely, if I click "edit html" in Chrome (well, here, Brave), it shows that starts with
&
so, for whatever reason, that&
is a literal&
in the render..)The text was updated successfully, but these errors were encountered: