-
Notifications
You must be signed in to change notification settings - Fork 154
feat: Message format as golang template #114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
v1.0.1 Release
|
Kudos, SonarCloud Quality Gate passed!
|
fopinappb
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think using go templates (and sprig) should be the default in every templated variable!
maybe for retro-compatibility it'd be nice to add some
if {{data}} in format {
deprecationWarning("update your config to use {{.Data}} instead of {{data}} as latter is deprecated")
msg = strings.replace(msg, "{{data}}","{{.Data}}")
}
|
Closing as not planned (dot prefixed variable names are a breaking change) - CC @ehsandeep |
@Mzack9999 if a clean proposal allowing retro compatibility, would it be ok? |
|
@fopina I'm reopening the PR for discussion @ehsandeep Shall we add an automatic conversion layer? On a side I find the syntax |
|
While the syntax in the current "find and replace" might be cleaner (and more natural to non-Gophers), the real advantage is supporting templating: conditions, loops, and, in this PR, all the sprig functions One useful function in this case (service message payloads) is escape markdown, as an example |








The message format is now a golang text template with access to the Sprig template functions.
Using the default format
{{.Data}}will have the same outcome as the previous functionality.This is an example of a Discord configuration: