-
-
Notifications
You must be signed in to change notification settings - Fork 331
Open
Description
Description:
Currently, when calling Render on a templ component, the Content-Type header is not set automatically. This requires users to manually set the appropriate header (e.g., "text/html; charset=utf-8") when serving components via HTTP.
This behavior can be surprising, especially since templ.Handler (or ComponentHandler) does handle the Content-Type when used with templ.WithContentType.
Proposal:
- Add clear documentation stating that users must set the
Content-Typeheader themselves when usingComponent.Render. - Optionally, consider whether
Component.Rendercould accept options (similar totempl.Handler) to set the header automatically, or state in the documentation that this isn’t the default.
Benefits:
- Prevents confusion and subtle bugs when serving HTML responses.
- Improves the developer experience by making expectations explicit.
As a side note, extend the go comment for the component handler, to make it clear that it should only be used to render static sites.
Metadata
Metadata
Assignees
Labels
No labels