view

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarkdownToHTML

func MarkdownToHTML(str string) (string, error)

MarkdownToHTML renders a Markdown string as HTML.

func MarkdownToHTMLFunc

func MarkdownToHTMLFunc() func(str string) template.HTML

MarkdownToHTMLFunc returns a function suitable for usage with html/template.

func PutFlashError

func PutFlashError(w http.ResponseWriter, message string)

PutFlashError sets a Flash that will be rendered as an error message.

func PutFlashInfo

func PutFlashInfo(w http.ResponseWriter, message string)

PutFlashInfo sets a Flash that will be rendered as an information message.

func PutFlashSuccess

func PutFlashSuccess(w http.ResponseWriter, message string)

PutFlashSuccess sets a Flash that will be rendered as a success message.

func PutFlashWarning

func PutFlashWarning(w http.ResponseWriter, message string)

PutFlashWarning sets a Flash that will be rendered as a warning message.

Types

type Data

type Data struct {
	AtomFeedURL string
	Content     any
	Flash       *flash
	Title       string
	User        *user.User
}

Data holds the data that can be rendered by views.

type ErrorView

type ErrorView struct {
	*View
}

ErrorView represents a Web View that will be rendered by the server in response to an HTTP client request resulting in an HTTP 4xx error status.

func NewError

func NewError() *ErrorView

NewError returns an initialized ErrorView, preconfigured with the default application templates and page-specific templates.

func (*ErrorView) Render

func (v *ErrorView) Render(w http.ResponseWriter, r *http.Request, statusCode int)

type FormContent

type FormContent struct {
	CSRFToken string
	Content   any
}

FormContent holds the data that can be rendered by a form, protected with a CSRF token.

type View

type View struct {
	Template *template.Template
}

View represents a Web View that will be rendered by the server in response to an HTTP client request.

func New

func New(templateFiles ...string) *View

New returns an initialized View, preconfigured with the default application templates and page-specific templates.

func (*View) Handle

func (v *View) Handle(w http.ResponseWriter, r *http.Request)

func (*View) Render

func (v *View) Render(w http.ResponseWriter, r *http.Request, data interface{})

Jump to

Keyboard shortcuts

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