Documentation
¶
Overview ¶
templ: version: v0.3.977
Index ¶
Constants ¶
const PreviewPath = "/preview/markdown"
PreviewPath is the standard handler path for markdown preview.
Variables ¶
This section is empty.
Functions ¶
func Markdown ¶
Markdown renders markdown content as HTML. It uses GitHub Flavored Markdown with typography extensions.
func MarkdownInput ¶
func MarkdownInput(props InputProps) templ.Component
MarkdownInput renders a textarea with Write/Preview tabs. Clicking Preview sends the markdown to the server via POST SSE, which renders it and patches the preview div.
func MustRender ¶
MustRender converts markdown to HTML, returning empty string on error. Errors are logged for debugging but do not cause panics. Raw HTML tags in the input are escaped for security.
func PreviewHandler ¶
func PreviewHandler() http.HandlerFunc
PreviewHandler returns an http.HandlerFunc that renders markdown from the component's signals and patches the preview div via SSE.
Mount at a dedicated POST path:
r.Post(markdown.PreviewPath, markdown.PreviewHandler())
Types ¶
type InputProps ¶
type InputProps struct {
// ID uniquely identifies this component instance. Required.
ID string
// Class adds additional CSS classes to the container.
Class string
// Attributes adds arbitrary HTML attributes to the container.
Attributes templ.Attributes
// Name is the form field name attribute.
Name string
// Placeholder is the textarea placeholder text.
Placeholder string
// Value is the initial textarea value.
Value string
// PreviewURL is the endpoint path for server-side preview rendering.
// The component appends "?id=<ID>" automatically.
PreviewURL string
// Rows is the textarea rows. Defaults to 8.
Rows int
}
InputProps configures a markdown input with Write/Preview tabs.
type Props ¶
type Props struct {
// Content is the markdown text to render.
Content string
// ID is the optional element ID.
ID string
// Class is additional CSS classes.
Class string
// Attributes is additional HTML attributes.
Attributes templ.Attributes
}
Props configures the Markdown display component.