Documentation
¶
Overview ¶
Package templated implements a lightweight mail templating mechanism.
Store your templates in dir "A", then Render will execute "A/base/index.html" as the main template for the mail body, adding any other files in "A/base" as helper templates, stylesheets, images etc. Other subfolders of "A", e.g. "A/en_US" should contain one file per templated message. These files should define 2 templates: "subject" and "body" (using the {{ define 'name"}} ... {{end}} syntax).
See the tests and the "example" folder for a demonstration.
Example ¶
cnf := Config{"example", "en_US"} ctx := map[string]interface{}{ "Name": "Test Customer", "Company": "ACME Coorp", } subj, body, err := Render(&cnf, "foo", ctx) if err != nil { fmt.Println(err) } fmt.Printf("Subject: %s\n", string(subj)) fmt.Printf("Body:\n%s\n", string(body))
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct { // Dir is the directory where your templates live. It's supposed to have a // subfolder named "base" in which the Render method will look for the main and // helper templates. Dir string // Lang names the language subfolder of Dir in which the file containing // the message specific templates named "subject" and "body" are located. Lang string }
Config helps you to manage your templates.
Click to show internal directories.
Click to hide internal directories.