Good read, Toph! Yes, the old HTML tagged template literal would implicitly trim surrounding whitespace, which made it hard to intentionally introduce whitespace. The new Hypertext Literal does not trim whitespace, which means that it needs to surround the content with an implicit SPAN element. Alternatively, you can use htl.html.fragment to get a DocumentFragment, which is useful if you’re going to interpolate that into another literal.
mbostock
6
Related topics
| Topic | Replies | Views | Activity | |
|---|---|---|---|---|
| Hypertext literal | 7 | 884 | December 16, 2019 | |
| Suprising behavior with html`` template and event handlers | 2 | 387 | June 17, 2021 | |
| html template: how to display? | 5 | 419 | March 28, 2024 | |
| hypertext literals in Framework | 2 | 162 | June 5, 2024 | |
| cells not rendering sometimes, possibly related to HTL | 2 | 335 | April 27, 2021 |