render

package
v0.0.0-...-a02f6fc Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HTML

func HTML(w http.ResponseWriter, r *http.Request, status int, templateName string)

func JSON

func JSON(w http.ResponseWriter, r *http.Request, status int, data any)

func Set

func Set(r *http.Request, name string, value interface{})

func SetFrame

func SetFrame(r *http.Request, name string)

func SetFrameArg

func SetFrameArg(r *http.Request, name string, value interface{})

func UseFrame

func UseFrame(r *http.Request, name string)

func XML

func XML(w http.ResponseWriter, r *http.Request, status int, data any)

Types

type Config

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

func New

func New(tmplFS fs.FS, opts ...ConfigOption) *Config

func (*Config) NewInv

func (tc *Config) NewInv() *Inv

func (*Config) Use

func (tc *Config) Use(next http.Handler) http.Handler

type ConfigOption

type ConfigOption func(config *Config)

func RebuildOnChange

func RebuildOnChange(ctx context.Context, baseDir string) ConfigOption

RebuildOnChange is a render option which will trigger the rebuild of the templates when a .html file within baseDir or any subdirectories are changed. If baseDir is the empty string, this will do nothing.

func WithDir

func WithDir(dir string) ConfigOption

WithDir sets the directory to search for templates, instead of just the the root. If unable to set the directory, this function will panic

func WithFrame

func WithFrame(frameTemplate string) ConfigOption

WithFrame adds a frame template, which is used to render the contents of template used in the request within another template. Frame templates are evaluated in reverse order, meaning any later fame templates are rendered in earlier order.

func WithFuncs

func WithFuncs(funcs template.FuncMap) ConfigOption

type Inv

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

func (*Inv) HTML

func (inv *Inv) HTML(w http.ResponseWriter, r *http.Request, status int, templateName string)

func (*Inv) JSON

func (inv *Inv) JSON(w http.ResponseWriter, r *http.Request, status int, data any)

func (*Inv) Set

func (inv *Inv) Set(name string, value any)

func (*Inv) SetFrame

func (inv *Inv) SetFrame(name string)

SetFrame will replace any pending frame with the given name.

func (*Inv) SetFrameArg

func (inv *Inv) SetFrameArg(name string, value any)

func (*Inv) UseFrame

func (inv *Inv) UseFrame(name string)

UseFrame adds the use of the frame to the pending frame stack.

func (*Inv) XML

func (inv *Inv) XML(w http.ResponseWriter, r *http.Request, status int, data any)

Jump to

Keyboard shortcuts

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