van icon indicating copy to clipboard operation
van copied to clipboard

Feature request: allow variable in html data custom attribute key

Open gleh opened this issue 2 months ago • 1 comments

The data-* form a class of attributes called custom data attributes, that allow proprietary information to be exchanged between the HTML and its DOM representation by scripts. I was wondering if it would be possible to extend the van tag definition in order to allow variables for custom part in data-* definitions. This would allow you to write e.g. td({ 'data-$(theCustomKey)` : id }, data). The current version requires to hardcode the whole data attribute key as string, which is really inconvenient in most of the use cases.

gleh avatar Nov 11 '25 18:11 gleh

Confused by this. I think we're already able to do td({ `data-${theCustomKey}` : id }, data), right?

Tao-VanJS avatar Nov 12 '25 21:11 Tao-VanJS

It throws "Uncaught SyntaxError: Unexpected template string (at ... )". I use src="https://cdn.jsdelivr.net/gh/vanjs-org/van/public/van-1.6.0.nomodule.debug.js"

gleh avatar Nov 16 '25 19:11 gleh

Your error message seems like a result of incorrect use of template literals in JavaScript. Could you show your code snippet so that I can take a look at what's going wrong?

Tao-VanJS avatar Nov 23 '25 00:11 Tao-VanJS