Documentation
¶
Index ¶
- Variables
- func GenerateNonce() (string, error)
- func If[T comparable](condition bool, value T) T
- func IfElse[T any](condition bool, trueValue T, falseValue T) T
- func LocalComponentScriptURL(component string) string
- func MergeAttributes(attrs ...templ.Attributes) templ.Attributes
- func RandomID() string
- func RemoteComponentScriptURL(component string) string
- func TwMerge(classes ...string) string
Constants ¶
This section is empty.
Variables ¶
var ( SuppressComponentScripts bool RemoteScriptCDNBase = "https://cdn.jsdelivr.net/gh/templui/templui" ComponentScriptURL = func(component string) string { return RemoteComponentScriptURL(component) } )
var ScriptURL = func(path string) string { return path + "?v=" + ScriptVersion }
ScriptURL generates cache-busted script URLs. Override this to use custom cache busting (CDN, content hashing, etc.)
Example override in your app:
func init() {
utils.ScriptURL = func(path string) string {
return myAssetManifest.GetURL(path)
}
}
var ScriptVersion = fmt.Sprintf("%d", time.Now().Unix())
ScriptVersion is a timestamp generated at app start for cache busting. Used in component script tags to append ?v=<timestamp> to script URLs.
Functions ¶
func GenerateNonce ¶
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 LocalComponentScriptURL ¶
func MergeAttributes ¶
func MergeAttributes(attrs ...templ.Attributes) templ.Attributes
MergeAttributes combines multiple Attributes into one. Example: MergeAttributes(attr1, attr2) → combined attributes
func RandomID ¶
func RandomID() string
RandomID generates a random ID string. Example: RandomID() → "id-1a2b3c"
Types ¶
This section is empty.