How do I add data attributes to a script using the HTML builder

I’m new to ember. is the h function that is used in some pages to build HTML part of the ember project? I haven’t been able to find documentation on it.
Searching “ember h javascript” doesn’t do the trick

The specific problem I am trying to solve is add a data attribute to a script tag I am creating.
e.g.

h("script", {src: "http://localhost:5000/pass.js", "data-space": "123"}),

This creates a script tag wit the correct src but the data-space attribute is missing.

2 Likes

Ah yeah. The only documentation we reference that I can find is virtual-dom/README.md at master · Matt-Esch/virtual-dom · GitHub and it’s sort of hidden in our codebase as a comment :slightly_smiling_face: Even with that I couldn’t find the answer you are looking for there. In any case, there is a topic here on Meta that does have the solution:

So based on the code you provided, it should work if you change it to the following:

h("script", { src: "http://localhost:5000/pass.js", attributes: { "data-space": "123" } }),
8 Likes

There is also this post that explains how the virtual dom / widget part of Discourse works:

6 Likes