templates

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BootStrap

func BootStrap()

BootStrap actions. This function must be called prior to any access to the templates Registry.

func LoadFromEtree

func LoadFromEtree(element *etree.Element)

LoadFromEtree reads the view given etree.Element, creates or updates the template and adds it to the template registry if it not already.

Types

type Collection

type Collection struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

A Collection of templates

func (*Collection) Abs

func (tc *Collection) Abs(base, name string) string

Abs calculates the path to a given template. Whenever a path must be resolved due to an import from another template, the base equals the parent template's path.

func (*Collection) Add

func (tc *Collection) Add(t *Template)

Add the given template to the Collection

func (*Collection) Get

func (tc *Collection) Get(pth string) (io.Reader, error)

Get returns an io.Reader where the template's content can be read from.

func (*Collection) GetByID

func (tc *Collection) GetByID(id string) *Template

GetByID returns the Template with the given id

func (*Collection) LoadFromEtree

func (tc *Collection) LoadFromEtree(element *etree.Element)

LoadFromEtree loads the given template given as Element into this collection.

type Template

type Template struct {
	*hweb.Template
	ID              string
	Priority        uint8
	Page            bool
	Optional        bool
	OptionalDefault bool
	// contains filtered or unexported fields
}

A Template holds information of a HWeb template

func (*Template) Content

func (t *Template) Content(lang string) []byte

Content returns the template data for the given language. Call with empty string to get the default language's data.

type TemplateRenderer

type TemplateRenderer struct {
	Template *hweb.Template
	Data     hweb.Context
}

A TemplateRenderer can render a template with the given data

func (TemplateRenderer) Render

Render this TemplateRenderer to the given ResponseWriter

func (TemplateRenderer) WriteContentType

func (tr TemplateRenderer) WriteContentType(w http.ResponseWriter)

WriteContentType of this TemplateRenderer

type TemplateSet

type TemplateSet struct {
	*hweb.TemplateSet
	// contains filtered or unexported fields
}

A TemplateSet is a set of pongo2 templates

var Registry *TemplateSet

Registry is the templates set of the application

func NewTemplateSet

func NewTemplateSet() *TemplateSet

NewTemplateSet returns a pointer to a new empty TemplateSet

func (*TemplateSet) Instance

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

Instance returns the TemplateRenderer given by its name with the given data

type TemplateXML

type TemplateXML struct {
	ID        string `xml:"id,attr"`
	InheritID string `xml:"inherit_id,attr"`
	Content   []byte `xml:",innerxml"`
	Priority  uint8  `xml:"priority,attr"`
	Page      string `xml:"page,attr"`
	Optional  string `xml:"optional,attr"`
}

TemplateXML is used to unmarshal the XML definition of a template

Jump to

Keyboard shortcuts

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