Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func init() {
- funcMap = template.FuncMap{
- "img": func(imgs []*templateAttachment, name string) (string, error) {
- for i := range imgs {
- if imgs[i].Name == name {
- return imgs[i].Path, nil
- }
- }
- return "", &AppError{
- Action: "FuncMap",
- Unit: "Template",
- Text: fmt.Sprintf("Image attachment %v is not found", name),
- }
- },
- }
- }
- func ParseTemplate(.....){
- ......
- templateParser, err := template.New("Email").Funcs(funcMap).Parse(content)
- if err != nil {
- return "", err
- }
- wr := bytes.NewBufferString("")
- err = templateParser.Execute(wr, tplVars)
- if err != nil {
- return "", err
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement