Documentation ¶
Overview ¶
Package template provides template support for letter bodies.
Index ¶
- func Data(ctx context.Context) interface{}
- func Disable(ctx context.Context) context.Context
- func Enable(ctx context.Context, name string, data interface{}) context.Context
- func For(ctx context.Context) (string, interface{}, bool)
- func Name(ctx context.Context) (string, bool)
- func Plugin(opts ...Option) postdog.PluginFunc
- func TryPlugin(opts ...Option) (postdog.PluginFunc, error)
- type Config
- type FuncMap
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Enable ¶
Enable sets the template that will be used to build the letter body for this context. Use the optional data that can be accesed in the template via {{ .Data }}
func For ¶
For returns the template and data that should be used for sending letters with ctx. Returns false if ctx has no template set.
func Name ¶
Name returns the template that should be used for sending letters with ctx. Returns false if ctx has no template set.
func Plugin ¶
func Plugin(opts ...Option) postdog.PluginFunc
Plugin creates the template plugin. It panics if it fails to parse the templates. Use TryPlugin() if you need to catch parse errors.
Example:
plugin := template.Plugin( template.UseDir("/templates") )
Types ¶
type Option ¶
type Option func(*Config)
Option is a plugin option.
func UseDir ¶
UseDir registers all files in dirs and their subdirectories as templates. The template name will be set to the relative path of the file to the given directory in dirs, where every directory separator is replaced by a dot and the file extensions is removed.
Example:
Given the following files: /templates/tpl1.html /templates/tpl2.html /templates/nested/tpl3.html /templates/nested/deeper/tpl4.html UseDir("/templates") will result in the following template names: - tpl1 - tpl2 - nested.tpl3 - nested.deeper.tpl4