render

package
v0.0.0-...-c0efb99 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BaseTemplatePath is the base template.
	BaseTemplatePath = "web/template/base.html.tmpl"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Renderer

type Renderer struct {

	// the compiled templates
	Template TemplateInterface
	// contains filtered or unexported fields
}

Renderer is the renderer.

func NewRenderer

func NewRenderer(envConfig *config.Environment, t TemplateInterface) *Renderer

NewRenderer creates a new renderer.

func (*Renderer) Error

func (r *Renderer) Error(w http.ResponseWriter, status int, message string, details error)

Error renders an error response.

func (*Renderer) GetLogOutput

func (r *Renderer) GetLogOutput() io.Writer

GetLogOutput returns the log output.

func (*Renderer) GetStaticDirectoryPath

func (r *Renderer) GetStaticDirectoryPath() string

GetStaticDirectoryPath returns the static directory path.

func (*Renderer) GetTemplateDirectoryPath

func (r *Renderer) GetTemplateDirectoryPath() string

GetTemplateDirectoryPath returns the template directory path.

func (*Renderer) JSON

func (r *Renderer) JSON(w http.ResponseWriter, status int, v interface{})

JSON renders a JSON response.

func (*Renderer) Status

func (r *Renderer) Status(w http.ResponseWriter, status int)

Status renders a status response with empty body.

type TemplateInterface

type TemplateInterface interface {
	SetBaseTemplate(baseTemplate string)
	AddTemplate(name string, files []string)
	RenderTemplate(w http.ResponseWriter, name string, data interface{}) error
}

TemplateInterface is an interface for Templates.

type Templates

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

Templates is a struct that holds the templates that we want to use.

func NewTemplates

func NewTemplates() *Templates

NewTemplates creates a new Templates struct.

func (*Templates) AddTemplate

func (t *Templates) AddTemplate(name string, files []string)

AddTemplate adds the templates to the Templates struct.

func (*Templates) RenderTemplate

func (t *Templates) RenderTemplate(w http.ResponseWriter, name string, data interface{}) error

RenderTemplate renders the template.

func (*Templates) SetBaseTemplate

func (t *Templates) SetBaseTemplate(baseTemplate string)

SetBaseTemplate sets the base template.

Jump to

Keyboard shortcuts

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