view

package
v6.0.0-...-03bcada Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2017 License: MIT, MIT Imports: 9 Imported by: 103

Documentation

Overview

Package view is the adaptor of the 5 template engines as written by me at https://github.com/kataras/go-template

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adaptor

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

Adaptor contains the common actions that all template engines share.

We need to export that as it is without an interface because it may be used as a wrapper for a template engine that is not exists yet but community can create.

func NewAdaptor

func NewAdaptor(directory string, extension string, e template.Engine) *Adaptor

NewAdaptor returns a new general template engine policy adaptor.

func (*Adaptor) Adapt

func (h *Adaptor) Adapt(frame *iris.Policies)

Adapt adapts a template engine to the main Iris' policies. this specific Adapt is a multi-policies adaptors we use that instead of just return New() iris.RenderPolicy for two reasons:

  • the user may need to edit the adaptor's fields like Directory, Binary
  • we need to adapt an event policy to add the engine to the external mux and load it.

func (*Adaptor) Binary

func (h *Adaptor) Binary(assetFn func(name string) ([]byte, error), namesFn func() []string) *Adaptor

Binary optionally, use it when template files are distributed inside the app executable (.go generated files).

func (*Adaptor) Reload

func (h *Adaptor) Reload(developmentMode bool) *Adaptor

Reload if setted to true the templates are reloading on each call, use it when you're in development and you're boring of restarting the whole app when you edit a template file

type AmberAdaptor

type AmberAdaptor struct {
	*Adaptor
	// contains filtered or unexported fields
}

AmberAdaptor is the adaptor for the Amber, simple, engine. Read more about the Amber Go Template at: https://github.com/eknkc/amber and https://github.com/kataras/go-template/tree/master/amber

func Amber

func Amber(directory string, extension string) *AmberAdaptor

Amber returns a new kataras/go-template/amber template engine with the same features as all iris' view engines have: Binary assets load (templates inside your executable with .go extension) Layout, Funcs, {{ url }} {{ urlpath}} for reverse routing and much more.

Read more: https://github.com/eknkc/amber

func (*AmberAdaptor) Funcs

func (a *AmberAdaptor) Funcs(funcMap map[string]interface{}) *AmberAdaptor

Funcs adds the elements of the argument map to the template's function map. It is legal to overwrite elements of the default actions: - url func(routeName string, args ...string) string - urlpath func(routeName string, args ...string) string - render func(fullPartialName string) (template.HTML, error).

type DjangoAdaptor

type DjangoAdaptor struct {
	*Adaptor
	// contains filtered or unexported fields
}

DjangoAdaptor is the adaptor for the Django engine. Read more about the Django Go Template at: https://github.com/flosch/pongo2 and https://github.com/kataras/go-template/tree/master/django

func Django

func Django(directory string, extension string) *DjangoAdaptor

Django returns a new kataras/go-template/django template engine with the same features as all iris' view engines have: Binary assets load (templates inside your executable with .go extension) Layout, Funcs, {{ url }} {{ urlpath}} for reverse routing and much more.

Read more: https://github.com/flosch/pongo2

func (*DjangoAdaptor) DebugTemplates

func (d *DjangoAdaptor) DebugTemplates(debug bool) *DjangoAdaptor

DebugTemplates enables template debugging. The verbose error messages will appear in browser instead of quiet passes with error code.

func (*DjangoAdaptor) Filters

func (d *DjangoAdaptor) Filters(filtersMap map[string]FilterFunction) *DjangoAdaptor

Filters for pongo2, map[name of the filter] the filter function .

Note, these Filters function overrides ALL the previous filters It SETS a new filter map based on the given 'filtersMap' parameter.

func (*DjangoAdaptor) Globals

func (d *DjangoAdaptor) Globals(globalsMap map[string]interface{}) *DjangoAdaptor

Globals share context fields between templates. https://github.com/flosch/pongo2/issues/35

type Error

type Error django.Error

Error conversion for django.Error

type FilterFunction

type FilterFunction func(in *Value, param *Value) (out *Value, err *Error)

FilterFunction conversion for django.FilterFunction

type HTMLAdaptor

type HTMLAdaptor struct {
	*Adaptor
	// contains filtered or unexported fields
}

HTMLAdaptor is the html engine policy adaptor used like the "html/template" standard go package but with a lot of extra features by.

This is just a wrapper of kataras/go-template/html.

func HTML

func HTML(directory string, extension string) *HTMLAdaptor

HTML creates and returns a new kataras/go-template/html engine. The html engine used like the "html/template" standard go package but with a lot of extra features.

func Pug

func Pug(directory string, extension string) *HTMLAdaptor

Pug (or Jade) returns a new kataras/go-template/pug engine. It shares the same exactly logic with the HTMLAdaptor, it uses the same exactly configuration. It has got some features and a lot of functions which will make your life easier. Read more about the Jade Go Template: https://github.com/Joker/jade

func (*HTMLAdaptor) Delims

func (h *HTMLAdaptor) Delims(left string, right string) *HTMLAdaptor

Delims sets the action delimiters to the specified strings, to be used in subsequent calls to Parse, ParseFiles, or ParseGlob. Nested template definitions will inherit the settings. An empty delimiter stands for the corresponding default: {{ or }}.

func (*HTMLAdaptor) Funcs

func (h *HTMLAdaptor) Funcs(funcMap map[string]interface{}) *HTMLAdaptor

Funcs adds the elements of the argument map to the template's function map. It is legal to overwrite elements of the default actions: - url func(routeName string, args ...string) string - urlpath func(routeName string, args ...string) string - render func(fullPartialName string) (template.HTML, error).

func (*HTMLAdaptor) Layout

func (h *HTMLAdaptor) Layout(tmplLayoutFile string) *HTMLAdaptor

Layout sets the layout template file which inside should use the {{ yield }} func to yield the main template file and optionally {{partial/partial_r/render}} to render other template files like headers and footers

The 'tmplLayoutFile' is a relative path of the templates base directory, for the template file with its extension.

Example: HTML("./templates", ".html").Layout("layouts/mainLayout.html")

// mainLayout.html is inside: "./templates/layouts/".

Note: Layout can be changed for a specific call action with the option: "layout" on the Iris' context.Render function.

func (*HTMLAdaptor) LayoutFuncs

func (h *HTMLAdaptor) LayoutFuncs(funcMap map[string]interface{}) *HTMLAdaptor

LayoutFuncs adds the elements of the argument map to the template's layout-only function map. It is legal to overwrite elements of the default layout actions: - yield func() (template.HTML, error) - current func() (string, error) - partial func(partialName string) (template.HTML, error) - partial_r func(partialName string) (template.HTML, error) - render func(fullPartialName string) (template.HTML, error).

type HandlebarsAdaptor

type HandlebarsAdaptor struct {
	*Adaptor
	// contains filtered or unexported fields
}

HandlebarsAdaptor is the adaptor for the Handlebars engine. Read more about the Handlebars Go Template at: https://github.com/aymerick/raymond and https://github.com/kataras/go-template/tree/master/handlebars

func Handlebars

func Handlebars(directory string, extension string) *HandlebarsAdaptor

Handlebars returns a new kataras/go-template/handlebars template engine with the same features as all iris' view engines have: Binary assets load (templates inside your executable with .go extension) Layout, Funcs, {{ url }} {{ urlpath}} for reverse routing and much more.

Read more: https://github.com/aymerick/raymond

func (*HandlebarsAdaptor) Funcs

func (h *HandlebarsAdaptor) Funcs(funcMap map[string]interface{}) *HandlebarsAdaptor

Funcs adds the elements of the argument map to the template's function map. It is legal to overwrite elements of the default actions: - url func(routeName string, args ...string) string - urlpath func(routeName string, args ...string) string - and handlebars specific, read more: https://github.com/aymerick/raymond.

func (*HandlebarsAdaptor) Layout

func (h *HandlebarsAdaptor) Layout(tmplLayoutFile string) *HandlebarsAdaptor

Layout sets the layout template file which inside should use the {{ yield }} func to yield the main template file and optionally {{partial/partial_r/render}} to render other template files like headers and footers

The 'tmplLayoutFile' is a relative path of the templates base directory, for the template file with its extension.

Example: Handlebars("./templates", ".html").Layout("layouts/mainLayout.html")

// mainLayout.html is inside: "./templates/layouts/".

Note: Layout can be changed for a specific call action with the option: "layout" on the Iris' context.Render function.

type Value

type Value django.Value

Value conversion for django.Value

Jump to

Keyboard shortcuts

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