ITADN

Support @html in `<title>` tag

#18144OpenSanqui 创建于 2026-04-26
S
Sanquicommented
### Describe the problem Svelte doesn't support the `<title>` tag containing `{@html ...}`: ```svelte <script> const htmlTitle = "Czecho&shy;slovak"; </script> <svelte:head> <title>{@html htmlTitle}</title> </svelte:head> ``` ``` `<title>` can only contain text and {tags} https://svelte.dev/e/title_invalid_content svelte[title_invalid_content](https://svelte.dev/docs/svelte/compiler-errors#title_invalid_content) ``` This is inconvenient for variable titles which contain XML markup that should be embedded directly, such as `&shy;` or `&nbsp;`. Without the `@html` directive, the XML entity gets mangled into `&amp;shy;`. ### Describe the proposed solution Svelte should relax this restriction, which seems arbitrary. Alternatively, Svelte should provide another way to pass variables containing XML entities to the `<title>` tag. ### Importance would make my life easier
3 条评论