template

package
v3.0.0-rc.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2016 License: Apache-2.0 Imports: 12 Imported by: 0

README

Folder Information

This folder contains the template support for Iris. The folder name is singular (template) so the /template/engine, because you can use ONLY ONE at the same time.

How to use

Refer to the Book

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterSharedFunc

func RegisterSharedFunc(name string, fn interface{})

RegisterSharedFunc registers a functionality that should be inherited from all supported template engines

func RegisterSharedFuncs

func RegisterSharedFuncs(theFuncs map[string]interface{})

RegisterSharedFuncs registers functionalities that should be inherited from all supported template engines

Types

type Engine

type Engine interface {
	// BuildTemplates builds the templates for a directory
	BuildTemplates() error
	// ExecuteWriter finds and execute a template and write its result to the out writer
	ExecuteWriter(out io.Writer, name string, binding interface{}, layout string) error
}

Engine the interface that all template engines must inheritance

type Template

type Template struct {
	// Engine the type of the Engine
	Engine Engine
	// Gzip enable gzip compression
	// default is false
	Gzip bool
	// IsDevelopment re-builds the templates on each request
	// default is false
	IsDevelopment bool
	// Directory the system path which the templates live
	// default is ./templates
	Directory string
	// Extensions the allowed file extension
	// default is []string{".html"}
	Extensions []string
	// ContentType is the Content-Type response header
	// default is text/html but you can change if if needed
	ContentType string
	// Layout the template file ( with its extension) which is the mother of all
	// use it to have it as a root file, and include others with {{ yield }}, refer  the docs
	Layout string
	// contains filtered or unexported fields
}

Template the internal configs for the common configs for the template engines

func New

func New(c config.Template) *Template

New creates and returns a Template instance which keeps the Template Engine and helps with render

func (*Template) Render

func (t *Template) Render(ctx context.IContext, name string, binding interface{}, layout ...string) (err error)

Render renders a template using the context's writer

func (*Template) RenderString

func (t *Template) RenderString(name string, binding interface{}, layout ...string) (result string, err error)

RenderString executes a template and returns its contents result (string)

Directories

Path Synopsis
engine
jade
Package jade the JadeEngine's functionality lives inside ../html now
Package jade the JadeEngine's functionality lives inside ../html now

Jump to

Keyboard shortcuts

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