Back to godoc.org

Package rendering

v3.1.0
Latest Go to latest

The latest major version is v4.

Published: Jun 11, 2019 | License: Apache-2.0 | Module: github.com/app-nerds/kit/v3

Index

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

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier