Documentation
¶
Overview ¶
Package utils provides utility functions for the web UI.
templui util templui.go - version: v1.0.0 installed by templui v1.0.0
Index ¶
- Variables
- func If[T comparable](condition bool, value T) T
- func IfElse[T any](condition bool, trueValue T, falseValue T) T
- func MergeAttributes(attrs ...templ.Attributes) templ.Attributes
- func ParseEnvFile(content string) map[string]string
- func RandomID() string
- func SerializeEnvFile(vars map[string]string) string
- func ToJSON(v any) string
- func TwMerge(classes ...string) string
Constants ¶
This section is empty.
Variables ¶
var ScriptVersion = fmt.Sprintf("%d", time.Now().Unix())
ScriptVersion is a timestamp generated at app start for cache busting. Used in Script() templates to append ?v=<timestamp> to script URLs.
Functions ¶
func If ¶
func If[T comparable](condition bool, value T) T
TwIf returns value if condition is true, otherwise an empty value of type T. Example: true, "bg-red-500" → "bg-red-500"
func IfElse ¶
TwIfElse returns trueValue if condition is true, otherwise falseValue. Example: true, "bg-red-500", "bg-gray-300" → "bg-red-500"
func MergeAttributes ¶
func MergeAttributes(attrs ...templ.Attributes) templ.Attributes
MergeAttributes combines multiple Attributes into one. Example: MergeAttributes(attr1, attr2) → combined attributes
func ParseEnvFile ¶
ParseEnvFile parses a .env file content and returns a map of key-value pairs. This implementation mirrors the JavaScript parseEnvFile function in env_form.templ. **Validates: Requirements 2.2, 2.3**
func RandomID ¶
func RandomID() string
RandomID generates a random ID string. Example: RandomID() → "id-1a2b3c"
func SerializeEnvFile ¶
SerializeEnvFile serializes a map of key-value pairs to .env file format. This is used for round-trip testing of the parser. **Validates: Requirements 2.2, 2.3**
Types ¶
This section is empty.