html

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package html provides HTML rendering capabilities using both Fiber's engine and standard template rendering with security headers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResponseSecurityHeadersFiber

func ResponseSecurityHeadersFiber(c *fiber.Ctx)

ResponseSecurityHeadersFiber sets the security headers for the response according to best practices

func ResponseSecurityHeadersStd

func ResponseSecurityHeadersStd(w http.ResponseWriter)

Types

type RendererFiber

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

func NewRendererFiber

func NewRendererFiber(reload bool, viewsfs embed.FS, extDir string, extension string) (*RendererFiber, error)

NewRendererFiber creates a new HTML renderer to be used in Fiber handlers. It supports both embedded templates (in viewsfs) and external templates (in extDir). If reload is true, the templates are loaded from the directory specified in extDir. If reload is false, the templates are loaded from the embedded directory. viewsfs is the filesystem containing the views. extDir is the directory containing the external templates.

func (*RendererFiber) Render

func (h *RendererFiber) Render(c *fiber.Ctx, templateName string, data map[string]any, layout ...string) error

type RendererStd

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

func NewRendererStd

func NewRendererStd(reload bool, viewsfs embed.FS, extDir string, extension string) (*RendererStd, error)

NewRendererStd creates a new HTML renderer to be used in standard http handlers. It supports both embedded templates (in viewsfs) and external templates (in extDir). If reload is true, the templates are loaded from the directory specified in extDir. If reload is false, the templates are loaded from the embedded directory. viewsfs is the filesystem containing the views. extDir is the directory containing the external templates.

func (*RendererStd) Render

func (h *RendererStd) Render(w http.ResponseWriter, templateName string, data map[string]any, layout ...string) error

func (*RendererStd) RenderToBuffer

func (h *RendererStd) RenderToBuffer(templateName string, data any) (*bytes.Buffer, error)

Jump to

Keyboard shortcuts

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