renderer

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TemplatesDir holds the location of the templates
	TemplatesDir = "templates/"
	// Layout is the file name of the layout file
	Layout = "layout"
	// Ext is the file extension of the rendered templates
	Ext = ".html"
	// Debug enables debug mode
	Debug = false
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Render

type Render struct {
	Templates    map[string]*template.Template
	Files        map[string][]string
	TemplatesDir string
	Layout       string
	Ext          string
	Debug        bool
}

Render implements gin's HTMLRender and provides some sugar on top of it

func New

func New() Render

New returns a fresh instance of Render

func (*Render) Add

func (r *Render) Add(name string, tmpl *template.Template)

Add assigns the name to the template

func (*Render) AddFromFiles

func (r *Render) AddFromFiles(name string, files ...string) *template.Template

AddFromFiles parses the files and returns the result

func (*Render) Create

func (r *Render) Create() *Render

Create goes through the `TemplatesDir` creating the template structure for rendering. Returns the Render instance.

func (*Render) Instance

func (r *Render) Instance(name string, data interface{}) render.Render

Instance implements gin's HTML render interface

func (*Render) Validate

func (r *Render) Validate()

Validate checks if the directory and the layout files exist as expected and configured

Jump to

Keyboard shortcuts

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