Documentation
¶
Index ¶
- Variables
- func GetProjectRootPath(subDirs ...string) (string, error)
- func LoadTemplates() error
- func RegisterFunc(name string, function interface{})
- func RenderServerErrorTemplate(w http.ResponseWriter, statusCode int, errMsg string)
- func RenderTemplate(w http.ResponseWriter, tmpl string, data interface{})
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 ¶
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.
Click to show internal directories.
Click to hide internal directories.