aboutsummaryrefslogtreecommitdiffstats
path: root/lib/templates/template.go
Commit message (Collapse)AuthorAgeFilesLines
* commands: expand and complete template codeKoni Marti2023-05-161-0/+52
| | | | | | | | | | | | | | | | | | | | | | | | | Expand and complete template code. The exline does understand template code and can evaluate it. With this patch, the completion systems supports writing the templates by showing the available template data fields and template functions. Pressing <Tab> after }} will show the evaluated template in the completion menu. Complex template code, such as if-else statements work as well. Examples: :filter -f {{<Tab> will show the possible template data fields and functions :filter -f {{index (.To|email) 0}}<Tab> will show the value of the template expression in the completion list Pressing <Tab> twice after a completed template expression will substitute the expression with its value. :{{if match .Folder "INBOX"}}check-mail{{else}}cf INBOX{{end}} Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* templates: unify data interfaceRobin Jarry2023-02-201-10/+9
| | | | | | | | | | | | | | | | | | | | | | | 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>
* templates: add more fields and functionsRobin Jarry2023-01-041-0/+4
| | | | | | | | | | | Add functions and fields in preparation for more than only message templates. The idea is to reuse the same symbols for the message list format and other parts of the UI. Update the man page accordingly. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* templates: split code in multiple filesRobin Jarry2023-01-041-182/+0
| | | | | | | This makes room in preparation for more code in here. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* lint: apply new formatting rulesMoritz Poldrack2022-08-011-2/+2
| | | | | | | Run `make fmt`. Signed-off-by: Moritz Poldrack <git@moritz.sh> Acked-by: Robin Jarry <robin@jarry.cc>
* config: do not hardcode sharedirRobin Jarry2022-02-191-0/+8
| | | | | | | | | | | | Instead of using a static SHAREDIR at compile time, use a list of standard paths to use at runtime for templates, config files and stylesets. This implies removing all default filters in the default configuration. Replace them with basic commands. New users can configure the filters as they wish. Signed-off-by: Robin Jarry <robin@jarry.cc>
* go.mod: change base git urlRobin Jarry2021-11-051-1/+1
| | | | | | | I'm not sure what are the implications but it seems required. Link: https://github.com/golang/go/issues/20883 Signed-off-by: Robin Jarry <robin@jarry.cc>
* compose: use a proper header instead of a string mapReto Brunner2020-11-141-33/+49
| | | | | | | | | | | | | Prior to this commit, the composer was based on a map[string]string. While this approach was very versatile, it lead to a constant encoding / decoding of addresses and other headers. This commit switches to a different model, where the composer is based on a header. Commands which want to interact with it can simply set some defaults they would like to have. Users can overwrite them however they like. In order to get access to the functions generating / getting the msgid go-message was upgraded.
* templates: Remove ParseTemplate as it's unusedReto Brunner2020-11-141-14/+0
|
* templates: better error messageReto Brunner2020-11-111-2/+3
|
* Fix dates in reply/forward commands.Reto Brunner2020-06-261-3/+2
| | | | | | The data was passed around as a string for some reason, which led to time precision loss and wrong dates being displayed. Simply pass the time as is to fix that.
* templates: add version funcReto Brunner2020-05-061-0/+8
| | | | Fixes #316
* Remove ability to specify headers in the editorReto Brunner2020-04-241-4/+5
| | | | | | | | | | Due to headers being essentially free text, we constantly run into issues with parts of the body being interpreted as headers. Remove the ability to overwrite headers to avoid that, while keeping the ability to specify headers in the template files. Fixes #383
* toLocal template functionsqwishy2020-02-251-0/+5
| | | | | | | | | | Hi. This adds a template function to convert a time to the local time zone. And modifies the default quoted_reply template to use it and show the time zone when formatting the timestamp of the quoted message. Previously, the quoted message timestamp was UTC and it would format it without the time zone. And I thought it might be a little confusing or weird to some normal people when I email them and I don't want normal people to be confused or think that I'm weird.
* template: add exec and wrapLeszek Cimała2020-01-091-0/+23
|
* template: remove last \n to fix additional new lines after quoteLeszek Cimała2020-01-091-0/+2
|
* add .OriginalMIMEType variable to reply templateLeszek Cimała2020-01-091-15/+18
|
* create OriginalMail structLeszek Cimała2020-01-091-12/+16
|
* Fix double >\n when quoting empty lineSrivathsan Murali2020-01-041-0/+1
|
* Correct capitalization in quoted_replyDrew DeVault2019-11-101-12/+32
|
* Add some defaults for template optionsDrew DeVault2019-11-101-2/+2
|
* Add Templates with ParsingSrivathsan Murali2019-11-101-0/+160
+ Changes NewComposer to return error. + Add lib to handle templates using "text/template". + Add -T option to following commands - compose. - reply - forward + Quoted replies using templates. + Forwards as body using templates + Default templates are installed similar to filters. + Templates Config in aerc.conf. - Required templates are parsed while loading config. + Add aerc-templates.7 manual for using template data.