template

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RenderFunc

type RenderFunc func(str string, params map[string]string) (string, error)
var (
	RenderNone RenderFunc = func(str string, params map[string]string) (string, error) {
		return str, nil
	}

	RenderPlain RenderFunc = func(str string, params map[string]string) (string, error) {
		tpl, err := texttpl.New("plain_email").Parse(str)
		if err != nil {
			return "", err
		}

		render := bytes.NewBuffer(make([]byte, 0, len(str)))
		if err = tpl.Execute(render, params); err != nil {
			return "", err
		}

		return render.String(), nil
	}

	RenderHTML RenderFunc = func(str string, params map[string]string) (string, error) {
		tpl, err := htmltpl.New("html_email").Parse(str)
		if err != nil {
			return "", err
		}

		render := bytes.NewBuffer(make([]byte, 0, len(str)))
		if err = tpl.Execute(render, params); err != nil {
			return "", err
		}

		return render.String(), nil
	}
)

Jump to

Keyboard shortcuts

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