gobuffalo / plush

The powerful template system that Go needs
MIT License
900 stars 56 forks source link

Render replacing special characters in input string with their ASCII code #163

Closed samirkape closed 2 years ago

samirkape commented 2 years ago

input := "New Equip <%= OrganizationName %>"
plushCtx.Set("OrganizationName", "\"'&")
renderedTemplate, err := plush.Render(template, plushCtx)
fmt.Println(renderedTemplate)

output: New Equip &#34;&#39;&amp;

samirkape commented 2 years ago

Is there any quick workaround? we have this code running in production

samirkape commented 2 years ago

I found a solution to the problem:

input := "New Equip <%= OrganizationName %>"
plushCtx.Set("OrganizationName", "\"'&")
renderedTemplate, err := plush.Render(template, plushCtx)
renderedTemplate = html.UnescapeString(renderedTemplate) // this will do the job
fmt.Println(renderedTemplate)

output: New Equip "'&