utils

package
v0.0.0-...-9e70112 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TemplateCache = make(map[string]*template.Template)
)

TemplateCache holds precompiled templates for efficient rendering.

Functions

func GetProjectRootPath

func GetProjectRootPath(subDirs ...string) (string, error)

GetProjectRootPath locates the project root directory by finding the go.mod file and appends any provided subdirectories to the path.

func LoadTemplates

func LoadTemplates() error

LoadTemplates loads and caches templates from the specified directory.

func RegisterFunc

func RegisterFunc(name string, function interface{})

RegisterFunc registers a custom function for use in templates.

func RenderServerErrorTemplate

func RenderServerErrorTemplate(w http.ResponseWriter, statusCode int, errMsg string)

RenderServerErrorTemplate renders a fallback error page for server errors.

func RenderTemplate

func RenderTemplate(w http.ResponseWriter, tmpl string, data interface{})

RenderTemplate renders a cached template with the given data.

Types

This section is empty.

Jump to

Keyboard shortcuts

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