aboutsummaryrefslogtreecommitdiffstats
path: root/config/columns.go
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2023-02-02 00:48:51 +0100
committerRobin Jarry <robin@jarry.cc>2023-02-20 14:40:59 +0100
commit9fa296fb762231d386db88913d1c2ea521bd813c (patch)
tree445bf6554084bb37e6aed479c9942b5afecb2149 /config/columns.go
parent28483808727fd288b95b9dd26a716f6cf7c02b5a (diff)
downloadaerc-9fa296fb762231d386db88913d1c2ea521bd813c.tar.gz
templates: unify data interface
Require that all aerc template data objects implement the same TemplateData interface. Implement that interface in two different places: 1) state.TemplateData (renamed/moved from templates.TemplateData). This structure (along with all its methods) needs to be decoupled from the templates package to break the import cycle with the config package. This allows much simpler construction of this object and ensure that values are calculated only when requested. 2) config.dummyData (extracted from templates). This is only used in the config package to validate user templates. Putting it here allows also to break an import cycle. Use state.TemplateData everywhere (including for account tabs title rendering). Signed-off-by: Robin Jarry <robin@jarry.cc> Reviewed-by: Moritz Poldrack <moritz@poldrack.dev>
Diffstat (limited to 'config/columns.go')
-rw-r--r--config/columns.go4
1 files changed, 1 insertions, 3 deletions
diff --git a/config/columns.go b/config/columns.go
index b1c7191b..55efa2a7 100644
--- a/config/columns.go
+++ b/config/columns.go
@@ -90,9 +90,7 @@ func parseColumnDef(col string, section *ini.Section) (*ColumnDef, error) {
return nil, err
}
- data := templates.DummyData()
- var buf bytes.Buffer
- err = t.Execute(&buf, data)
+ err = templates.Render(t, &bytes.Buffer{}, &dummyData{})
if err != nil {
return nil, err
}