Documentation
¶
Index ¶
- Variables
- func GeneratedTemplate(f func(GeneratedComponentInput) error) templ.Component
- func GetBuilder() (sb strings.Builder)
- func ReleaseBuffer(w io.Writer) (err error)
- func SanitizeStyleAttributeValues(values ...any) (string, error)
- func WriteString(w io.Writer, index int, s string) (err error)
- type Buffer
- type GeneratedComponentInput
Constants ¶
This section is empty.
Variables ¶
var DefaultBufferSize = 4 * 1024 // 4KB
DefaultBufferSize is the default size of buffers. It is set to 4KB by default, which is the same as the default buffer size of bufio.Writer.
var ErrInvalidStyleAttributeFunctionSignature = errors.New("invalid function signature, should be in the form func() (string, error)")
var TemplUnsupportedStyleAttributeValue = "zTemplUnsupportedStyleAttributeValue:Invalid;"
TemplUnsupportedStyleAttributeValue is the default value returned for unsupported types.
Functions ¶
func GeneratedTemplate ¶
func GeneratedTemplate(f func(GeneratedComponentInput) error) templ.Component
GeneratedTemplate is used to avoid generated code needing to import the `context` and `io` packages.
func ReleaseBuffer ¶
ReleaseBuffer flushes the buffer and returns it to the pool.
func SanitizeStyleAttributeValues ¶ added in v0.3.833
SanitizeStyleAttributeValues renders a style attribute value. The supported types are: - string - templ.SafeCSS - map[string]string - map[string]templ.SafeCSSProperty - templ.KeyValue[string, string] - A map of key/values where the key is the CSS property name and the value is the CSS property value. - templ.KeyValue[string, templ.SafeCSSProperty] - A map of key/values where the key is the CSS property name and the value is the CSS property value. - templ.KeyValue[string, bool] - The bool determines whether the value should be included. - templ.KeyValue[templ.SafeCSS, bool] - The bool determines whether the value should be included. - func() (anyOfTheAboveTypes) - func() (anyOfTheAboveTypes, error) - []anyOfTheAboveTypes
In the above, templ.SafeCSS and templ.SafeCSSProperty are types that are used to indicate that the value is safe to render as CSS without sanitization. All other types are sanitized before rendering.
If an error is returned by any function, or a non-nil error is included in the input, the error is returned.
Types ¶
type Buffer ¶
Buffer is a wrapper around bufio.Writer that enables flushing and closing of the underlying writer.
func GetBuffer ¶
GetBuffer creates and returns a new buffer if the writer is not already a buffer, or returns the existing buffer if it is.
func (*Buffer) Close ¶
Close closes the buffer and the underlying io.Writer if it implements io.Closer.
func (*Buffer) Flush ¶
Flush writes any buffered data to the underlying io.Writer and calls the Flush method of the underlying http.Flusher if it implements it.