You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the above example, the data types seem to be working as intended when they're just in simple template fields. The second they're in a structure though, it all falls apart and everything gets escaped, even types who's purpose (my understanding) is to not be escaped in this context. 😦
What did you expect to see?
Either JS or JSStr URLs in obj.Broken (above) which aren't escaped.
What did you see instead?
Everything in the obj (above) is being escaped, including JS and JSStr types.
The text was updated successfully, but these errors were encountered:
This looks like it is working as intended. You are inside a js context here, so JS and JSStr do what you want (as your link demonstrates).
When you use a struct directly in your template (or in this case an array of structs), it will be converted to a String for printing - in this context that will be escaped. So it is not doing what you expect for that reason.
If instead you want to provide unescaped content, perhaps add a function to your struct which returns the content you want as a JSStr type - don't attempt to use the printing of structs using String - instead use the JSStr type. Here is an example:
This sort of question is probably more suited to stackoverflow (at least until you're very sure there is a bug). If not a bug you should close this issue.
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go version go1.9 linux/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?Fedora 25, x64
What did you do?
Just trying to find any working method to pass URLs with parameters in them (eg "?foo=1&bar=2")
through to a template, for use by AngularJS.
Unfortunately, none of the data types (HTML, HTMLAttr, JS, JSStr, URL) seem able to suppress escaping:
https://play.golang.org/p/pgNKYoHKV0
In the above example, the data types seem to be working as intended when they're just in simple template fields. The second they're in a structure though, it all falls apart and everything gets escaped, even types who's purpose (my understanding) is to not be escaped in this context. 😦
What did you expect to see?
Either JS or JSStr URLs in obj.Broken (above) which aren't escaped.
What did you see instead?
Everything in the obj (above) is being escaped, including JS and JSStr types.
The text was updated successfully, but these errors were encountered: