Add some defaults for template options
This commit is contained in:
parent
3ba69edab5
commit
cb7d7a0438
3 changed files with 15 additions and 5 deletions
|
@ -319,7 +319,9 @@ func (config *AercConfig) LoadConfig(file *ini.File) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
templateDirs := templatesSec.Key("template-dirs").String()
|
templateDirs := templatesSec.Key("template-dirs").String()
|
||||||
|
if templateDirs != "" {
|
||||||
config.Templates.TemplateDirs = strings.Split(templateDirs, ":")
|
config.Templates.TemplateDirs = strings.Split(templateDirs, ":")
|
||||||
|
}
|
||||||
for key, val := range templatesSec.KeysHash() {
|
for key, val := range templatesSec.KeysHash() {
|
||||||
if key == "template-dirs" {
|
if key == "template-dirs" {
|
||||||
continue
|
continue
|
||||||
|
@ -404,6 +406,12 @@ func LoadConfigFromFile(root *string, sharedir string) (*AercConfig, error) {
|
||||||
{"Subject"},
|
{"Subject"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Templates: TemplateConfig{
|
||||||
|
TemplateDirs: []string{path.Join(sharedir, "templates")},
|
||||||
|
QuotedReply: "quoted_reply",
|
||||||
|
Forwards: "forward_as_body",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
// These bindings are not configurable
|
// These bindings are not configurable
|
||||||
config.Bindings.AccountWizard.ExKey = KeyStroke{
|
config.Bindings.AccountWizard.ExKey = KeyStroke{
|
||||||
|
|
|
@ -132,8 +132,8 @@ func ParseTemplateFromFile(templateName string, templateDirs []string, data inte
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
emailTemplate, err :=
|
emailTemplate, err := template.New(templateName).
|
||||||
template.New(templateName).Funcs(templateFuncs).ParseFiles(templateFile)
|
Funcs(templateFuncs).ParseFiles(templateFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,8 @@ type Composer struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewComposer(aerc *Aerc, conf *config.AercConfig,
|
func NewComposer(aerc *Aerc, conf *config.AercConfig,
|
||||||
acct *config.AccountConfig, worker *types.Worker, template string, defaults map[string]string) (*Composer, error) {
|
acct *config.AccountConfig, worker *types.Worker, template string,
|
||||||
|
defaults map[string]string) (*Composer, error) {
|
||||||
|
|
||||||
if defaults == nil {
|
if defaults == nil {
|
||||||
defaults = make(map[string]string)
|
defaults = make(map[string]string)
|
||||||
|
@ -173,7 +174,8 @@ func (c *Composer) AddTemplate(template string, data interface{}) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
templateText, err := templates.ParseTemplateFromFile(template, c.config.Templates.TemplateDirs, data)
|
templateText, err := templates.ParseTemplateFromFile(
|
||||||
|
template, c.config.Templates.TemplateDirs, data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue