Documentation
¶
Overview ¶
templ: version: v0.3.1001
templ: version: v0.3.1001
Package helpers provides shared components for templ templates.
templ: version: v0.3.1001
templ: version: v0.3.1001
templ: version: v0.3.1001
templ: version: v0.3.1001
templ: version: v0.3.1001
templ: version: v0.3.1001
templ: version: v0.3.1001
templ: version: v0.3.1001
templ: version: v0.3.1001
templ: version: v0.3.1001
templ: version: v0.3.1001
templ: version: v0.3.1001
templ: version: v0.3.1001
Index ¶
- Variables
- func Ago(t time.Time) templ.Component
- func AssetPath(ctx context.Context, path string) (string, error)
- func Authenticated(ctx context.Context) bool
- func Avatar(url *string) templ.Component
- func BareLayout(props BareLayoutProps) templ.Component
- func Cookie(ctx context.Context, name string) string
- func CopyableContent() templ.Component
- func CurrentPath(ctx context.Context) string
- func CurrentURL(ctx context.Context) string
- func CurrentURLWithoutQuery(ctx context.Context) string
- func CurrentUserAvatar() templ.Component
- func CurrentUsername(ctx context.Context) (string, error)
- func DeleteButton() templ.Component
- func EditButton() templ.Component
- func Error(r *http.Request, w http.ResponseWriter, err string, opts ...ErrorOption)
- func ExternalIcon() templ.Component
- func Filter[T ~string](props FilterProps[T]) templ.Component
- func FilterLabel(status runstatus.Status) templ.Component
- func FlashError(w http.ResponseWriter, msg string)
- func FlashSuccess(w http.ResponseWriter, msg string)
- func FlashWarning(w http.ResponseWriter, msg string)
- func Flashes() templ.Component
- func Identifier(id resource.TfeID) templ.Component
- func IsOwner(ctx context.Context, organization resource.ID) bool
- func IsSiteAdmin(ctx context.Context) bool
- func Layout(props LayoutProps) templ.Component
- func MarkdownToHTML(md []byte) template.HTML
- func MenuItem(title string, path string, matchPrefixes ...string) templ.Component
- func MergeQuery(u string, q string) (templ.SafeURL, error)
- func OrganizationMenu(organization resource.ID) templ.Component
- func PollingTable[T any](populator TablePopulator[T], page *resource.Page[T]) templ.Component
- func Render(c templ.Component, w http.ResponseWriter, r *http.Request, ...)
- func RenderPage(c templ.Component, title string, w http.ResponseWriter, r *http.Request, ...)
- func RenderSnippet(c templ.Component, w io.Writer, r *http.Request) error
- func RequestFromContext(ctx context.Context) *http.Request
- func ResponseFromContext(ctx context.Context) http.ResponseWriter
- func ReturnUserOriginalPage(w http.ResponseWriter, r *http.Request)
- func RunStatusBadge(runID resource.TfeID, status runstatus.Status) templ.Component
- func RunStatusFilter(selected []runstatus.Status, visible bool) templ.Component
- func SearchDropdown(props SearchDropdownProps) templ.Component
- func SendUserToLoginPage(w http.ResponseWriter, r *http.Request)
- func SetCookie(w http.ResponseWriter, name, value string, expiry *time.Time)
- func SiteMenu() templ.Component
- func Strikethrough(cond bool) templ.Component
- func Table[T any](populator TablePopulator[T], page *resource.Page[T]) templ.Component
- func ToBytes(comp templ.Component) []byte
- func ToString(comp templ.Component) string
- func TokenFlashMessage(w gohttp.ResponseWriter, token []byte) error
- func UnpaginatedTable[T any](populator TablePopulator[T], resources []T) templ.Component
- func WorkspaceMenu(workspace resource.Info, organization resource.ID, authorizer authz.Interface) templ.Component
- type BareLayoutProps
- type Breadcrumb
- type DropDownUIWidth
- type ErrorOption
- type FilterProps
- type Flash
- type FlashStack
- type FlashType
- type LayoutProps
- type RenderOption
- type RenderPageOption
- func WithBreadcrumbs(crumbs ...Breadcrumb) RenderPageOption
- func WithContentActions(comp templ.Component) RenderPageOption
- func WithOrganization(org resource.ID) RenderPageOption
- func WithPostContent(comp templ.Component) RenderPageOption
- func WithPreContent(comp templ.Component) RenderPageOption
- func WithWorkspace(ws *workspace.Workspace, authorizer authz.Interface) RenderPageOption
- type SearchDropdownProps
- type TablePopulator
Constants ¶
This section is empty.
Variables ¶
var RunStatusThemeMappings = map[runstatus.Status]string{ runstatus.Applied: "success", runstatus.ApplyQueued: "secondary", runstatus.Applying: "accent", runstatus.Canceled: "warning", runstatus.Confirmed: "info", runstatus.Discarded: "warning", runstatus.Errored: "error", runstatus.ForceCanceled: "warning", runstatus.Pending: "primary", runstatus.PlanQueued: "secondary", runstatus.Planned: "info", runstatus.PlannedAndFinished: "success", runstatus.Planning: "primary", }
Functions ¶
func Authenticated ¶
func BareLayout ¶
func BareLayout(props BareLayoutProps) templ.Component
func CopyableContent ¶
func CurrentPath ¶
func CurrentURL ¶
func CurrentURLWithoutQuery ¶
func CurrentUserAvatar ¶
func DeleteButton ¶
func EditButton ¶
func Error ¶ added in v0.5.18
func Error(r *http.Request, w http.ResponseWriter, err string, opts ...ErrorOption)
Error sends an appropriate error response to an http request. If the request was to carry out an operation, i.e. a POST action, then a flash message is set and the user is redirected to the last page. Otherwise it's assumed the request was a normal page navigation request, i.e. a GET action, and an error notice is rendered with an optional status code, defaulting to HTTP500.
func ExternalIcon ¶
func FlashError ¶ added in v0.5.18
func FlashError(w http.ResponseWriter, msg string)
FlashError helper writes a single flash error message
func FlashSuccess ¶ added in v0.5.18
func FlashSuccess(w http.ResponseWriter, msg string)
FlashSuccess helper writes a single flash success message
func FlashWarning ¶ added in v0.5.18
func FlashWarning(w http.ResponseWriter, msg string)
FlashWarning helper writes a single flash warning message
func IsSiteAdmin ¶
func Layout ¶
func Layout(props LayoutProps) templ.Component
func MarkdownToHTML ¶ added in v0.5.18
func MergeQuery ¶ added in v0.5.18
MergeQuery merges the query string into the given url, replacing any existing query parameters with the same name.
func PollingTable ¶
PollingTable renders a table that polls for updates every X seconds.
func Render ¶ added in v0.5.18
func Render(c templ.Component, w http.ResponseWriter, r *http.Request, renderOptions ...RenderOption)
Render a template. Wraps the upstream templ handler to carry out additional actions every time a template is rendered.
func RenderPage ¶ added in v0.5.18
func RenderPage(c templ.Component, title string, w http.ResponseWriter, r *http.Request, opts ...RenderPageOption)
RenderPage renders a component within a layout, e.g. header, footer, menus etc.
func RenderSnippet ¶ added in v0.5.18
func RequestFromContext ¶ added in v0.5.18
func ResponseFromContext ¶ added in v0.5.18
func ResponseFromContext(ctx context.Context) http.ResponseWriter
func ReturnUserOriginalPage ¶ added in v0.5.18
func ReturnUserOriginalPage(w http.ResponseWriter, r *http.Request)
ReturnUserOriginalPage returns a user to the original page they tried to access before they were redirected to the login page.
func RunStatusBadge ¶ added in v0.5.18
func RunStatusFilter ¶ added in v0.5.18
func SearchDropdown ¶
func SearchDropdown(props SearchDropdownProps) templ.Component
func SendUserToLoginPage ¶ added in v0.5.18
func SendUserToLoginPage(w http.ResponseWriter, r *http.Request)
SendUserToLoginPage sends user to the login prompt page, saving the original path they tried to access so it can return them there after login.
func SetCookie ¶ added in v0.5.18
func SetCookie(w http.ResponseWriter, name, value string, expiry *time.Time)
SetCookie sets a cookie on the http response. A nil expiry sets no expiry, and a zero expiry sets it to be purged from the browser.
func Strikethrough ¶
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
Types ¶
type BareLayoutProps ¶
type Breadcrumb ¶
type DropDownUIWidth ¶
type DropDownUIWidth string
const ( NarrowDropDown DropDownUIWidth = "narrow" WideDropDown DropDownUIWidth = "wide" )
type ErrorOption ¶ added in v0.5.18
type ErrorOption func(*errorConfig)
func WithStatus ¶ added in v0.5.18
func WithStatus(statusCode int) ErrorOption
type FilterProps ¶
type Flash ¶ added in v0.5.18
Flash is a Flash message for the web UI
func PopFlashes ¶ added in v0.5.18
PopFlashes pops all flash messages off the stack
type FlashStack ¶ added in v0.5.18
type FlashStack []Flash
FlashStack is a stack of flash messages
func (*FlashStack) Push ¶ added in v0.5.18
func (s *FlashStack) Push(t FlashType, msg string)
func (FlashStack) Write ¶ added in v0.5.18
func (s FlashStack) Write(w http.ResponseWriter)
type LayoutProps ¶
type RenderOption ¶ added in v0.5.18
func WithChildren ¶ added in v0.5.18
func WithChildren(comp templ.Component) RenderOption
type RenderPageOption ¶ added in v0.5.18
type RenderPageOption func(opts *LayoutProps)
func WithBreadcrumbs ¶ added in v0.5.18
func WithBreadcrumbs(crumbs ...Breadcrumb) RenderPageOption
func WithContentActions ¶ added in v0.5.18
func WithContentActions(comp templ.Component) RenderPageOption
func WithOrganization ¶ added in v0.5.18
func WithOrganization(org resource.ID) RenderPageOption
func WithPostContent ¶ added in v0.5.18
func WithPostContent(comp templ.Component) RenderPageOption
func WithPreContent ¶ added in v0.5.18
func WithPreContent(comp templ.Component) RenderPageOption
func WithWorkspace ¶ added in v0.5.18
func WithWorkspace(ws *workspace.Workspace, authorizer authz.Interface) RenderPageOption
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
}
Source Files
¶
- buttons_templ.go
- clipboard_templ.go
- components.go
- cookies.go
- dropdown_templ.go
- error.go
- filter_templ.go
- flash.go
- flash_templ.go
- functions.go
- helpers.go
- html.go
- icons_templ.go
- layout_templ.go
- menu_templ.go
- render.go
- strikethrough_templ.go
- table_templ.go
- theme_chooser_templ.go
- time_templ.go
- token_templ.go
- user_templ.go
- view_templ.go