Documentation
¶
Index ¶
- func LoadTemplate(path string) (*template.Template, error)
- func ParseAddressInput(input string) ([]string, error)
- func ReadTextInput(textArg string) (string, error)
- func RenderTemplate(recipient parser.Recipient, templatePath string) (string, error)
- func SplitAndTrim(s string) []string
- func StartPreviewServer(rendered string, port int) error
- type TemplateCache
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadTemplate ¶ added in v1.1.0
LoadTemplate parses and caches an HTML template file by its path. The path is canonicalized so "./template.html" and "template.html" share a cache entry.
func ParseAddressInput ¶ added in v1.1.0
ParseAddressInput to parse --cc / --bcc from inline or file input. If the input is an existing file path, it reads emails from the file. Otherwise, it treats the input as comma-separated emails.
func ReadTextInput ¶ added in v1.0.0
ReadTextInput returns the body from inline --text or file path. It checks if the argument is an existing file path, otherwise treats it as inline text.
func RenderTemplate ¶ added in v1.1.0
RenderTemplate renders an HTML template with the given recipient's data. Recipient fields are accessible in templates as {{ .email }}, {{ .name }}, etc.
func SplitAndTrim ¶ added in v1.0.0
SplitAndTrim splits comma-separated string and trims whitespace from each email.
func StartPreviewServer ¶ added in v1.1.0
StartPreviewServer starts a local HTTP server to preview the rendered email. Returns an error if the server fails to start or serve.
Types ¶
type TemplateCache ¶ added in v1.1.0
type TemplateCache struct {
// contains filtered or unexported fields
}
TemplateCache is a bounded, TTL-based cache for parsed templates. Keys are canonical (absolute) file paths.