rendering

package
v5.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2021 License: Apache-2.0 Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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