Documentation
¶
Overview ¶
Package render writes template values into a page, each with the escaper of the HTML context it lands in. Generated code calls it; apps do not.
Index ¶
- Constants
- func Attr(w io.Writer, v any) error
- func Format(v any) string
- func HTML(w io.Writer, v web.SafeHTML) error
- func If[T any](cond bool, whenTrue, whenFalse T) T
- func JSON(w io.Writer, v any) error
- func Text(w io.Writer, v any) error
- func URL(w io.Writer, v any) error
- func URLPart(w io.Writer, v any) error
- func URLPathStart(w io.Writer, v any) error
- func URLQuery(w io.Writer, v any) error
Constants ¶
const UnsafeURL = "about:invalid#aicoded-unsafe-url"
UnsafeURL replaces a URL value whose scheme is not http, https or mailto.
Variables ¶
This section is empty.
Functions ¶
func If ¶
If returns whenTrue if cond holds and whenFalse otherwise. Templates write it as cond ? a : b.
func URL ¶
URL writes v as a whole URL attribute value, as in href="{{ link }}". A value whose scheme is not http, https or mailto becomes UnsafeURL.
func URLPart ¶
URLPart writes v in a URL attribute value after a fixed path or scheme and before any ? or #, as in href="/notes/{{ id }}".
func URLPathStart ¶
URLPathStart writes v in a URL attribute value right after its leading "/", as in href="/{{ slug }}". It encodes a leading "/" of v and writes an empty v as ".", so the URL never starts with "//" or "/\", which browsers read as the address of another site.
Types ¶
This section is empty.