@@ -37,31 +37,35 @@ func New(opts Options) (*Client, error) {
3737}
3838
3939// RenderMarkdown returns a notification message as markdown
40- func (c * Client ) RenderMarkdown () (title []byte , body []byte , err error ) {
40+ func (c * Client ) RenderMarkdown () (title []byte , body []byte , _ error ) {
4141 var titleBuf bytes.Buffer
42- titleTpl := template .Must (template .New ("title" ).Funcs (c .opts .TemplateFuncs ).Parse (strings .TrimSuffix (strings .TrimSpace (c .opts .TemplateTitle ), "\n " )))
43- err = titleTpl .Execute (& titleBuf , struct {
42+ titleTpl , err := template .New ("title" ).Funcs (c .opts .TemplateFuncs ).Parse (strings .TrimSuffix (strings .TrimSpace (c .opts .TemplateTitle ), "\n " ))
43+ if err != nil {
44+ return title , body , errors .Wrap (err , "Cannot parse title template" )
45+ }
46+ if err = titleTpl .Execute (& titleBuf , struct {
4447 Meta model.Meta
4548 Entry model.NotifEntry
4649 }{
4750 Meta : c .opts .Meta ,
4851 Entry : c .opts .Entry ,
49- })
50- if err != nil {
52+ }); err != nil {
5153 return title , body , errors .Wrap (err , "Cannot render notif title" )
5254 }
5355 title = titleBuf .Bytes ()
5456
5557 var bodyBuf bytes.Buffer
56- bodyTpl := template .Must (template .New ("body" ).Funcs (c .opts .TemplateFuncs ).Parse (strings .TrimSuffix (strings .TrimSpace (c .opts .TemplateBody ), "\n " )))
57- err = bodyTpl .Execute (& bodyBuf , struct {
58+ bodyTpl , err := template .New ("body" ).Funcs (c .opts .TemplateFuncs ).Parse (strings .TrimSuffix (strings .TrimSpace (c .opts .TemplateBody ), "\n " ))
59+ if err != nil {
60+ return title , body , errors .Wrap (err , "Cannot parse body template" )
61+ }
62+ if err = bodyTpl .Execute (& bodyBuf , struct {
5863 Meta model.Meta
5964 Entry model.NotifEntry
6065 }{
6166 Meta : c .opts .Meta ,
6267 Entry : c .opts .Entry ,
63- })
64- if err != nil {
68+ }); err != nil {
6569 return title , body , errors .Wrap (err , "Cannot render notif body" )
6670 }
6771 body = bodyBuf .Bytes ()
0 commit comments