render

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Render package renders HTML templates found in the rootpath/views folder of the project. Go and Jet templating engines can be used. See https://github.com/CloudyKit/jet for full documentation on Jet. Expected filenaming for Go templates <template_name>.page.tmpl, for Jet templates <template_name>.jet.

This package has built in CSRF protection with https://github.com/justinas/nosurf.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Renderer

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

func New

func New(rootpath, engine string, debug bool) *Renderer

createRenderer

func (*Renderer) GoPage

func (r *Renderer) GoPage(w http.ResponseWriter, req *http.Request, view string, data interface{}) error

GoPage renders a template using the GO templating engine.

func (*Renderer) JetPage

func (r *Renderer) JetPage(w http.ResponseWriter, req *http.Request, view string, variables interface{}, data interface{}) error

JetPage renders a template using the Jet templating engine.

func (*Renderer) Page

func (r *Renderer) Page(w http.ResponseWriter, req *http.Request, view string, variables interface{}, data interface{}) error

Page renders a page with the configured engine call the respective methods to render with a specific engine.

type TemplateData

type TemplateData struct {
	IsAuthenticated bool
	IntMap          map[string]int
	StringMap       map[string]string
	FloatMap        map[string]float32
	Data            map[string]interface{}
	CSRFToken       string
}

Jump to

Keyboard shortcuts

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