helpers

package
v0.5.9 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2026 License: MPL-2.0 Imports: 18 Imported by: 0

Documentation

Overview

templ: version: v0.3.977

templ: version: v0.3.977

Package helpers provides shared components for templ templates.

templ: version: v0.3.977

templ: version: v0.3.977

templ: version: v0.3.977

templ: version: v0.3.977

templ: version: v0.3.977

templ: version: v0.3.977

templ: version: v0.3.977

templ: version: v0.3.977

templ: version: v0.3.977

templ: version: v0.3.977

templ: version: v0.3.977

templ: version: v0.3.977

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Ago

func Ago(t time.Time) templ.Component

func AssetPath

func AssetPath(ctx context.Context, path string) (string, error)

func Authenticated

func Authenticated(ctx context.Context) bool

func Avatar

func Avatar(url *string) templ.Component

func BareLayout

func BareLayout(props BareLayoutProps) templ.Component
func Cookie(ctx context.Context, name string) string

func CopyableContent

func CopyableContent() templ.Component

func CurrentPath

func CurrentPath(ctx context.Context) string

func CurrentURL

func CurrentURL(ctx context.Context) string

func CurrentURLWithoutQuery

func CurrentURLWithoutQuery(ctx context.Context) string

func CurrentUserAvatar

func CurrentUserAvatar() templ.Component

func CurrentUsername

func CurrentUsername(ctx context.Context) (string, error)

func DeleteButton

func DeleteButton() templ.Component

func EditButton

func EditButton() templ.Component

func ExternalIcon

func ExternalIcon() templ.Component

func Filter

func Filter[T ~string](props FilterProps[T]) templ.Component

func Flashes

func Flashes() templ.Component

func Identifier

func Identifier(id resource.TfeID) templ.Component

func IsOwner

func IsOwner(ctx context.Context, organization resource.ID) bool

func IsSiteAdmin

func IsSiteAdmin(ctx context.Context) bool

func Layout

func Layout(props LayoutProps) templ.Component
func MenuItem(title string, path string, matchPrefixes ...string) templ.Component

func OrganizationMenu

func OrganizationMenu(organization resource.ID) templ.Component

func PollingTable

func PollingTable[T any](populator TablePopulator[T], page *resource.Page[T]) templ.Component

PollingTable renders a table that polls for updates every X seconds.

func SearchDropdown

func SearchDropdown(props SearchDropdownProps) templ.Component
func SiteMenu() templ.Component

func Strikethrough

func Strikethrough(cond bool) templ.Component

func Table

func Table[T any](populator TablePopulator[T], page *resource.Page[T]) templ.Component

func ToBytes

func ToBytes(comp templ.Component) []byte

func ToString

func ToString(comp templ.Component) string

func TokenFlashMessage

func TokenFlashMessage(w gohttp.ResponseWriter, token []byte) error

TokenFlashMessage is a helper for rendering a flash message with an authentication token.

func UnpaginatedTable

func UnpaginatedTable[T any](populator TablePopulator[T], resources []T) templ.Component

func WorkspaceMenu

func WorkspaceMenu(workspace resource.Info, organization resource.ID, authorizer authz.Interface) templ.Component

Types

type BareLayoutProps

type BareLayoutProps struct {
	Title        string
	Organization resource.ID
	Workspace    *resource.Info
	Menu         templ.Component
	PreContent   templ.Component
	PostContent  templ.Component
}
type Breadcrumb struct {
	Name string
	Link string
}
type DropDownUIWidth string
const (
	NarrowDropDown DropDownUIWidth = "narrow"
	WideDropDown   DropDownUIWidth = "wide"
)

type FilterProps

type FilterProps[T ~string] struct {
	Title            string
	All              []T
	Selected         []T
	ParamName        string
	Visible          bool
	VisibleParamName string
	Label            func(T) templ.Component
	CheckboxClass    func(T) string
}

type LayoutProps

type LayoutProps struct {
	Authorizer     authz.Interface
	Title          string
	Organization   resource.ID
	Workspace      *resource.Info
	Breadcrumbs    []Breadcrumb
	ContentActions templ.Component
	ContentMenu    templ.Component
	PreContent     templ.Component
	PostContent    templ.Component
}

type SearchDropdownProps

type SearchDropdownProps struct {
	// Name to send along with value in the POST form
	Name string
	// Existing values to NOT show in the dropdown
	Existing []string
	// Available values to show in the dropdown
	Available []string
	// Action is the form action URL
	Action templ.SafeURL
	// Placeholder to show in the input element.
	Placeholder string
	// Width: "narrow" or "wide"
	Width DropDownUIWidth
}

type TablePopulator

type TablePopulator[T any] interface {
	Header() templ.Component
	Row(T) templ.Component
}

TablePopulator populates a table component with resources of type T.

Jump to

Keyboard shortcuts

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