rendering

package
v4.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IRenderer

type IRenderer interface {
	AddTemplates(templateItems ...*Template) error
	AddTemplatesWithLayout(templateItems ...*TemplateWithLayout) error
	LoadFile(fileName string) string
	Render(w io.Writer, name string, data interface{}, ctx echo.Context) error
	SetDebug(value bool)
}

IRenderer defines an interface for a renderer

type Renderer

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

Renderer implements the Echo renderer and IRenderer interfaces

func NewRenderer

func NewRenderer(logger *logrus.Entry) *Renderer

NewRenderer creates a new renderer component with an empty set of templates

func (*Renderer) AddTemplates

func (r *Renderer) AddTemplates(templateItems ...*Template) error

AddTemplates adds one or more templates

func (*Renderer) AddTemplatesWithLayout

func (r *Renderer) AddTemplatesWithLayout(templateItems ...*TemplateWithLayout) error

AddTemplatesWithLayout adds one ore more templates with layouts

func (*Renderer) LoadFile

func (r *Renderer) LoadFile(fileName string) string

LoadFile reads all the contents of a file

func (*Renderer) Render

func (r *Renderer) Render(w io.Writer, name string, data interface{}, ctx echo.Context) error

Render renders a template by name to the supplied writer

func (*Renderer) SetDebug

func (r *Renderer) SetDebug(value bool)

type Template

type Template struct {
	Name        string
	PageContent string
}

A Template is a simple Go template with a name

type TemplateWithLayout

type TemplateWithLayout struct {
	LayoutContent string
	Name          string
	PageContent   string
}

A TemplateWithLayout describes a template to be rendered. This includes the template's layout, name, and content

Jump to

Keyboard shortcuts

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