template

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Assets = union.New(map[string]http.FileSystem{
	"/templates": filter.Keep(
		http.Dir("../template"),
		func(path string, fi os.FileInfo) bool {
			return path == "/" || path == "/default.tmpl"
		},
	),
})

Assets contains the project's assets.

View Source
var DefaultFuncs = FuncMap{
	"toUpper": strings.ToUpper,
	"toLower": strings.ToLower,
	"title":   strings.Title,

	"join": func(sep string, s []string) string {
		return strings.Join(s, sep)
	},
	"match": regexp.MatchString,
	"safeHtml": func(text string) tmplhtml.HTML {
		return tmplhtml.HTML(text)
	},
	"reReplaceAll": func(pattern, repl, text string) string {
		re := regexp.MustCompile(pattern)
		return re.ReplaceAllString(text, repl)
	},
	"stringSlice": func(s ...string) []string {
		return s
	},
	"markdown": markdownEscapeString,
}

Functions

This section is empty.

Types

type FuncMap

type FuncMap map[string]interface{}

type Template

type Template struct {
	ExternalURL *url.URL
	// contains filtered or unexported fields
}

Template bundles a text and a html template instance.

func FromGlobs

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

func (*Template) ExecuteHTMLString

func (t *Template) ExecuteHTMLString(html string, data interface{}) (string, error)

ExecuteHTMLString needs a meaningful doc comment (TODO(fabxc)).

func (*Template) ExecuteTextString

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

ExecuteTextString needs a meaningful doc comment (TODO(fabxc)).

Jump to

Keyboard shortcuts

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