plugin

package
v0.0.0-...-55d16bb Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2017 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Must

func Must(err error)

Must will on error panic.

func MustFatal

func MustFatal(err error)

Must will log the error and exit the application.

func Register

func Register(p Plugin, o *Opts) (err error)

Register registers a new plugin.

Types

type Args

type Args map[string]string

type Data

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

func GetData

func GetData(c *template.Context) (*Data, error)

GetData obtains the plugin data from the context. The context has to be a plugin context.

func (*Data) Args

func (d *Data) Args() Args

Args returns the plugin template arguments.

func (*Data) Section

func (d *Data) Section() interface{}

Section returns the plugin template section.

func (*Data) Value

func (d *Data) Value() interface{}

Value returns the interface value which was returned by the Prepare method.

type Opts

type Opts struct {
	Type       string // The plugin type.
	HasSection bool   // If the plugin requires a template section.
	RequireID  bool   // If the plugin requires a unique ID as argument.
}

type Plugin

type Plugin interface {
	Initialize() *template.Template                  // Called only once during plugin initialization.
	Prepare(d *Data) interface{}                     // Prepare is called for each plugin context. Settings should be parsed...
	Render(c *template.Context, d *Data) interface{} // Render is called during each plugin template rendering request. Template render data can be returned.
}

Jump to

Keyboard shortcuts

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