renderer

package
v0.0.0-...-ed79b10 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HTMLRender

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

HTMLRender accepts templates and a layout that will parse all necessary html files.

func NewHTMLRenderer

func NewHTMLRenderer(cfg ...HTMLRenderConfig) *HTMLRender

The constructor for the HTMLRender.

func (*HTMLRender) AddHook

func (r *HTMLRender) AddHook(hook RendererHook)

Allows adding a hook to modify data globally.

func (*HTMLRender) Render

func (r *HTMLRender) Render(w http.ResponseWriter, req *http.Request, name string, data map[string]any) hypergon.HypergonError

Render renders a html page with layout. The name must unique so it wont be a conflict to other html pages.

func (*HTMLRender) RenderPartial

func (r *HTMLRender) RenderPartial(w http.ResponseWriter, name string, data any) error

RenderPartial renders a partial template without the layout The name must unique so it wont be a conflict to other partial htmls.

type HTMLRenderConfig

type HTMLRenderConfig struct {
	// Layout name declaration.
	// Default: "layout.html"
	Layout string
	// TemplateDirs where you declare where are your html templates are in.
	//
	// Default:  []string{"templates", "templates/partials"}
	TemplateDirs []string
}

type JSONRenderer

type JSONRenderer struct{}

JSONRenderer object.

func NewJSONRenderer

func NewJSONRenderer() *JSONRenderer

JSONRenderer constructor.

func (*JSONRenderer) JSON

JSON functions returns a json response.

type RendererHook

type RendererHook func(http.ResponseWriter, *http.Request, map[string]any)

Jump to

Keyboard shortcuts

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