Documentation
¶
Overview ¶
templui util templui.go - version: v1.12.1 installed by templui v1.12.1
Index ¶
- Constants
- Variables
- func ComponentScript(component string) templ.Component
- func If[T any](condition bool, value T) T
- func IfElse[T any](condition bool, trueValue T, falseValue T) T
- func MergeAttributes(attrs ...templ.Attributes) templ.Attributes
- func RandomID() string
- func SetupScriptRoutes(mux *http.ServeMux, isDevelopment bool)
- func TwMerge(classes ...string) string
Constants ¶
const Version = "0.1.7"
Version is the current application version, used in the Swagger docs and shown in the web UI. Only change this when releasing a new version of the application.
Variables ¶
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.
var UseUnminifiedScripts = false
UseUnminifiedScripts switches component script loading to the unminified files. Leave this false in normal use and set it to true during app startup for debugging.
Functions ¶
func ComponentScript ¶
ComponentScript renders a deferred script tag for a component JavaScript file. Example: ComponentScript("datepicker") → <script defer src="/templui/js/datepicker.min.js?..."></script>
func If ¶
If returns value if condition is true, otherwise the zero value of T. Example: true, "bg-red-500" → "bg-red-500"
func IfElse ¶
IfElse 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 RandomID ¶
func RandomID() string
RandomID generates a random ID string. Example: RandomID() → "id-1a2b3c"
func SetupScriptRoutes ¶
SetupScriptRoutes serves embedded component JavaScript files for the import workflow. Example: SetupScriptRoutes(mux, true) mounts /templui/js/*.js with no-store caching in development.
Types ¶
This section is empty.