handlers

package
v0.0.25 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FSTemplateHandler added in v0.0.18

type FSTemplateHandler struct {
	fs.FS                         // Embedding file system interface to access templates.
	Patterns  []string            // Selecting templates within the FS.
	FuncMap   template.FuncMap    // Custom template functions.
	GetModel  TemplateModelGetter // Function to get the model for a given template.
	Root      *template.Template  // Root template object.
	DebugMode bool                // Flag to indicate debug mode.
	Log       *slog.Logger        // Logger instance.
	// contains filtered or unexported fields
}

FSTemplateHandler is a struct that handles template rendering from a file system.

func NewFSTemplateHandler added in v0.0.18

func NewFSTemplateHandler(fs fs.FS, patterns ...string) FSTemplateHandler

NewFSTemplateHandler creates a new instance of FSTemplateHandler with the provided file system and file patterns.

func (FSTemplateHandler) Parse added in v0.0.18

Parse parses the templates from the file system.

func (FSTemplateHandler) ServeHTTP added in v0.0.18

func (s FSTemplateHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP handles HTTP requests and renders templates.

func (FSTemplateHandler) WithDebug added in v0.0.18

func (s FSTemplateHandler) WithDebug() FSTemplateHandler

WithDebug enables debug mode.

func (FSTemplateHandler) WithFuncs added in v0.0.18

WithFuncs sets custom functions to be used in templates.

func (FSTemplateHandler) WithLog added in v0.0.18

WithLog sets the logger for the handler.

func (FSTemplateHandler) WithModelGetter added in v0.0.18

func (s FSTemplateHandler) WithModelGetter(getter TemplateModelGetter) FSTemplateHandler

WithModelGetter sets the function to retrieve models for templates.

func (FSTemplateHandler) WithModelMap added in v0.0.18

func (s FSTemplateHandler) WithModelMap(modelMap map[string]any) FSTemplateHandler

WithModelMap sets a map of models for templates.

type TemplateModelGetter added in v0.0.18

type TemplateModelGetter func(template string) any

TemplateModelGetter is a function type that takes a template name and returns a model (data) for that template.

Jump to

Keyboard shortcuts

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