Help us shape the future of Go! Take the 2026 Go Developer Survey

utils

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 13, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package utils provides shared helpers for the Outtake web layer.

Index

Constants

View Source
const ControlClass = "" /* 300-byte string literal not displayed */

ControlClass is the shared class list for text inputs and native selects.

Variables

View Source
var ScriptURL = assets.URL

ScriptURL names a script by a URL that carries a hash of its contents, so the browser fetches it again only when it changes.

View Source
var UseUnminifiedScripts = false

UseUnminifiedScripts switches component script loading to the unminified files.

Functions

func ComponentScript

func ComponentScript(component string) templ.Component

ComponentScript renders a deferred script tag for a component JavaScript file.

Parameters:

  • component: Component name whose script is loaded.

Returns:

  • script: A component rendering the script tag.

func If

func If[T any](condition bool, value T) T

If returns value when condition is true and the zero value of T otherwise.

Parameters:

  • condition: Whether to return value.
  • value: The value to return when condition is true.

Returns:

  • result: value when condition is true, otherwise the zero value of T.

func IfElse

func IfElse[T any](condition bool, trueValue, falseValue T) T

IfElse returns one of two values based on condition.

Parameters:

  • condition: Whether to return trueValue.
  • trueValue: The value to return when condition is true.
  • falseValue: The value to return when condition is false.

Returns:

  • result: trueValue when condition is true, otherwise falseValue.

func RandomID

func RandomID() string

RandomID generates a random ID string.

Returns:

  • id: The generated identifier, prefixed with "id-".

func TwMerge

func TwMerge(classes ...string) string

TwMerge combines Tailwind classes and resolves conflicts.

Parameters:

  • classes: Class lists to combine. Later classes win a conflict.

Returns:

  • merged: The combined classes with conflicts resolved.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL