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

templates

package
v3.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package templates compiles and renders web page and email templates.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Validate

func Validate(dir string) error

Validate checks that all effective templates compile and render.

Types

type ConnectorData

type ConnectorData struct {
	ID, DisplayName, URL string
	Email                bool
}

ConnectorData describes a sign-in option rendered by the selector.

type ConsentData

type ConsentData struct {
	PageData
	Title, State, ClientID string
}

ConsentData supplies data to the offline-access consent template.

type EmailData

type EmailData struct {
	Address  string
	Verified bool
	Primary  bool
}

EmailData describes one selectable upstream email assertion.

type ErrorData

type ErrorData struct {
	PageData
	Title, Message string
}

ErrorData supplies data to the error page template.

type GrantData

type GrantData struct {
	SID, ClientID, Mode, ActionToken, Email string
	CreatedAt, LastUsedAt, ExpiresAt        time.Time
}

GrantData describes one active grant and its one-use revocation action.

type GrantsData

type GrantsData struct {
	PageData
	Title, Email, Message string
	Grants                []GrantData
}

GrantsData supplies the self-service grant management page.

type IdentityData

type IdentityData struct {
	PageData
	Title  string
	Token  string
	Emails []EmailData
}

IdentityData supplies data to the identity selection template.

type Manager

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

Manager owns the compiled page and email templates.

func Load

func Load(dir string) (*Manager, error)

Load compiles each page with the effective common layout and test-renders all templates.

func (*Manager) HandlePublic

func (m *Manager) HandlePublic(w http.ResponseWriter, r *http.Request, pageData PageData)

HandlePublic serves public files and renders the error template for unmatched paths.

func (*Manager) RenderEmail

func (m *Manager) RenderEmail(w io.Writer, format string, data OTPEmailData) error

RenderEmail renders an OTP email in the requested format.

func (*Manager) RenderEmailSubject

func (m *Manager) RenderEmailSubject(data OTPEmailData) (string, error)

RenderEmailSubject renders and validates an OTP email subject.

func (*Manager) RenderPage

func (m *Manager) RenderPage(w io.Writer, name string, data any) error

RenderPage renders a named HTML page.

type OTPData

type OTPData struct {
	PageData
	Title, ChallengeID, Message, Error, Email string
	ExpiresIn, RetryAfter                     time.Duration
	ExpiresAt                                 time.Time
	RetryAfterSeconds                         int64
}

OTPData supplies data to the OTP entry template.

type OTPEmailData

type OTPEmailData struct {
	Code      string
	ExpiresAt time.Time
	ExpiresIn time.Duration
}

OTPEmailData supplies data to OTP email templates.

type PageData

type PageData struct {
	Request     RequestData
	IssuerURL   string
	HomepageURL string
}

PageData supplies common, non-sensitive context to browser page templates.

type RequestData

type RequestData struct{ Method, Host, Path string }

RequestData supplies non-sensitive request metadata to browser page templates.

type SelectorData

type SelectorData struct {
	PageData
	Title      string
	Screen     string
	State      string
	SiteKey    string
	Connectors []ConnectorData
}

SelectorData supplies data to the sign-in selector template.

Jump to

Keyboard shortcuts

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