Skip to content
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

Helpers dont seem to work with variadic parameters #14

Open
quii opened this issue Apr 19, 2017 · 3 comments
Open

Helpers dont seem to work with variadic parameters #14

quii opened this issue Apr 19, 2017 · 3 comments

Comments

@quii
Copy link

quii commented Apr 19, 2017

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

@ddivanshu
Copy link

ddivanshu commented Jul 15, 2020

Did you find any solution to above?

@ivoputzer
Copy link

any update or has anyone found a solution to this?

@pbedat
Copy link

pbedat commented Nov 3, 2023

I fixed this on a fork of the mailgun/raymond repo: mailgun/raymond@master...pbedat:raymond:master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants