raymond
raymond copied to clipboard
Helpers dont seem to work with variadic parameters
raymond.RegisterHelper("addParamsToLink", func(link string, params ...string) string {
// details not important
return "banana"
})
template, _ := raymond.Parse(`{{addParamsToLink baseLink parameter second}}`)
// and a test
t.Run("adds two parameters to url with parameter", func(t *testing.T) {
context := map[string]string{
"baseLink": "localhost:8080/?time=now",
"parameter": "drink=beer",
"second": "place=bar",
}
result, _ := template.Exec(context)
assert.Equal(t, "localhost:8080/?time=now&drink=beer&place=bar", result, "adds two parameters simple url")
})
The test fails because the helper seems to return an empty string. I suspect it is panic-ing silently.
If I remove the vararg-ness it returns banana
Did you find any solution to above?
any update or has anyone found a solution to this?
I fixed this on a fork of the mailgun/raymond repo: https://github.com/mailgun/raymond/compare/master...pbedat:raymond:master