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

encoding/json: shows #ZgotmplZ in a custom attribute with name "data-data" but not with "data-go" #12648

emilgpa opened this issue Sep 16, 2015 · 2 comments


Copy link

@emilgpa emilgpa commented Sep 16, 2015

The error occurs when marshal a struct in a HTML inside of a custom attribute with name data-data but not with other name (for example, data-go)

@ianlancetaylor ianlancetaylor changed the title shows #ZgotmplZ in a custom attribute with name "data-data" but not with "data-go" encoding/json: shows #ZgotmplZ in a custom attribute with name "data-data" but not with "data-go" Sep 16, 2015
@ianlancetaylor ianlancetaylor added this to the Unplanned milestone Sep 16, 2015
Copy link

@nussjustin nussjustin commented Nov 26, 2017

I took a look this since I'm currently playing with the html/template package.

When checking the type of known attributes the html/template package removes "data-" prefixes so it can handle things like data-href or data-src as URLs or prevent unsafe values for fields like data-method. So data-data becomes only data (at least for the type checking). Since data is a known attribute used to specify the URLs for <object>'s the parser treats it, and thus data-data, as URL.

So I'd say this works as intended. But we should at least update the documentation to state that data-* attributes and attributes with namespaces are handled as if they had no data- prefix / namespace.

Copy link

@gopherbot gopherbot commented Nov 26, 2017

Change mentions this issue: html/template: document handling of namespaced and data- attributes

@gopherbot gopherbot closed this in 683ef8c Sep 27, 2019
@golang golang locked and limited conversation to collaborators Sep 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.