diff options
author | Koni Marti <koni.marti@gmail.com> | 2023-05-06 11:30:48 +0200 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2023-05-16 17:12:00 +0200 |
commit | 30c1a30168dfff8ca5eecb8d0fa42ab4b638f79d (patch) | |
tree | 97d177a8e399ed7ad7f107b85df1cd4d246e50ff /widgets/account.go | |
parent | 6b6aaf3ae131971d05ab3f849ea3db14c6a6e055 (diff) | |
download | aerc-30c1a30168dfff8ca5eecb8d0fa42ab4b638f79d.tar.gz |
templates: use template interface consistently
Use the template interface consistently. Before, we have exported the
state.TemplateData struct and used it in most places instead of the
models.TemplateData interface. This lead to some inconsistencies, i.e.
Role() has been defined on the exported struct but not on the interface.
Unexport the state.TemplateData struct, add a DataSetter interface to
set the data needed for the template data and call the Data() method
which returns a models.TemplateData interface when the template data is
needed.
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Tim Culverhouse <tim@timculverhouse.com>
Diffstat (limited to 'widgets/account.go')
-rw-r--r-- | widgets/account.go | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/widgets/account.go b/widgets/account.go index e28804de..d76333d2 100644 --- a/widgets/account.go +++ b/widgets/account.go @@ -605,17 +605,17 @@ func (acct *AccountView) Vsplit(n int) error { // setTitle executes the title template and sets the tab title func (acct *AccountView) setTitle() { - var data state.TemplateData - if acct.tab == nil { return } + + data := state.NewDataSetter() data.SetAccount(acct.acct) data.SetFolder(acct.Directories().SelectedDirectory()) data.SetRUE(acct.dirlist.List(), acct.dirlist.GetRUECount) var buf bytes.Buffer - err := templates.Render(acct.uiConf.TabTitleAccount, &buf, &data) + err := templates.Render(acct.uiConf.TabTitleAccount, &buf, data.Data()) if err != nil { acct.PushError(err) return |