inCaller / prometheus_bot

Telegram bot for prometheus alerting
MIT License
397 stars 183 forks source link

Template works only from current directory #14

Closed hryamzik closed 7 years ago

hryamzik commented 7 years ago

template_path: "testdata/default.tmpl" doesn't work.

strangeman commented 7 years ago

https://golang.org/pkg/text/template/#Template.ParseFiles

ParseFiles parses the named files and associates the resulting templates with t. If an error occurs, parsing stops and the returned template is nil; otherwise it is t. There must be at least one file. Since the templates created by ParseFiles are named by the base names of the argument files, t should usually have the name of one of the (base) names of the files. If it does not, depending on t's contents before calling ParseFiles, t.Execute may fail. In that case use t.ExecuteTemplate to execute a valid template.

I fixed it. Will push in the same PR with https://github.com/inCaller/prometheus_bot/issues/13