templates

package
v0.0.0-...-e247606 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2025 License: MIT Imports: 9 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultCacheBuster = random.String(10)
)

Functions

func Add

func Add(a, b int) string

Add adds two integers for use in templates

func Sub

func Sub(a, b int) string

Sub subtracts two integers for use in templates

Types

type BaseContext

type BaseContext interface {
	// IsAuth returns whether the user is authenticated
	IsAuth() bool

	GetAuthUser() *ent.User

	// GetPath returns the current request path
	GetPath() string

	// GetCSRF returns the CSRF token for the current request
	GetCSRF() string
}

BaseContext defines the minimum interface required by all templates

type FuncMap

type FuncMap struct {
	// contains filtered or unexported fields
}

func NewFuncMap

func NewFuncMap(web *echo.Echo, cacheBuster string) *FuncMap

NewFuncMap provides a template function map

func (*FuncMap) File

func (fm *FuncMap) File(filepath string) templ.SafeURL

File appends a cache buster to a given filepath

func (fm *FuncMap) Link(url, text, currentPath string, classes ...string) templ.Component

Link outputs HTML for a Link element with active class support

func (*FuncMap) URL

func (fm *FuncMap) URL(routeName string, params ...any) templ.SafeURL

URL generates a URL from a given route name and optional parameters

type PageContext

type PageContext interface {
	BaseContext

	// GetTitle returns the page title
	GetTitle() string

	// GetAppName returns the application name
	GetAppName() string

	// GetMessages gets all flash messages for a given type
	GetMessages(typ msg.Type) []template.HTML

	// GetHTMXRequest returns the HTMX request information
	GetHTMXRequest() any

	// GetData returns the page-specific data
	GetData() any

	GetPager() page.Pager

	URL(routeName string, params ...any) templ.SafeURL

	File(file string) templ.SafeURL

	Link(url, text, currentPath string, classes ...string) templ.Component
}

PageContext defines the interface required by page templates

Jump to

Keyboard shortcuts

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