template

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2019 License: Apache-2.0 Imports: 12 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Assets = func() http.FileSystem {
	wd, err := os.Getwd()
	if err != nil {
		panic(err)
	}

	var assetsPrefix string
	switch path.Base(wd) {
	case "prometheus-webhook-dingtalk":

		assetsPrefix = "./"
	case "template":

		assetsPrefix = "../"
	}

	templates := filter.Keep(
		http.Dir(path.Join(assetsPrefix, "template")),
		func(path string, fi os.FileInfo) bool {
			return path == "/" || path == "/default.tmpl"
		},
	)

	return union.New(map[string]http.FileSystem{
		"/templates": templates,
	})
}()

Assets contains the project's assets.

Functions

This section is empty.

Types

type Template

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

func FromGlobs

func FromGlobs(paths ...string) (*Template, error)

FromGlobs calls ParseGlob on all path globs provided and returns the resulting tmpl.

func (*Template) ExecuteTextString

func (t *Template) ExecuteTextString(text string, data interface{}) (string, error)

Jump to

Keyboard shortcuts

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