views

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2023 License: BSD-3-Clause Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Render

func Render[D any](w io.Writer, name string, data Model[D]) error

func RenderErrorPage

func RenderErrorPage(w http.ResponseWriter, r *http.Request, err error)

func SetFlashMessage added in v0.3.0

func SetFlashMessage(ctx context.Context, typ FlashMessageType, text string)

Types

type DocumentViewModel

type DocumentViewModel struct {
	Global Global
	Body   string
	Data   any
}

type ErrorPageErr

type ErrorPageErr struct {
	Err     error
	Code    int
	Title   string
	Message string
}

func (ErrorPageErr) Error added in v0.3.0

func (err ErrorPageErr) Error() string

type FlashMessage added in v0.3.0

type FlashMessage struct {
	Type FlashMessageType
	Text string
}

type FlashMessageType added in v0.3.0

type FlashMessageType string
const (
	FlashMessageSuccess FlashMessageType = "success"
	FlashMessageError   FlashMessageType = "error"
)

type Global

type Global struct {
	Title        string
	CSRFToken    string
	FlashMessage FlashMessage
	CurrentURL   *url.URL
	Version      string
	Referer      string
	User         *auth.User
}

func NewGlobal

func NewGlobal(title string, r *http.Request) Global

type Model

type Model[D any] struct {
	Global Global
	Data   D
}

type Pagination added in v0.4.0

type Pagination[Item any] struct {
	*entities.ListPage[Item]

	URL *url.URL
}

func (*Pagination[Item]) NextPageURL added in v0.4.0

func (p *Pagination[Item]) NextPageURL() string

func (*Pagination[Item]) PageURL added in v0.4.0

func (p *Pagination[Item]) PageURL(n int) string

func (*Pagination[Item]) PaginationURLs added in v0.4.0

func (p *Pagination[Item]) PaginationURLs() []PaginationURL

func (*Pagination[Item]) PrevPageURL added in v0.4.0

func (p *Pagination[Item]) PrevPageURL() string

type PaginationURL added in v0.4.0

type PaginationURL struct {
	URL       string
	Text      string
	IsCurrent bool
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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