DomTemplate
DomTemplate copied to clipboard
Group data-bind keys by a category
Within HTML, there might be an element that contains lots of data-binds for, say, a User, and another element that contains lots of data-binds for an Order.
The User's element might have things like "id" or "name" as bind keys, which would clash with the data within an Order.
When using bindData(), it's still really useful to refer to the direct fields of the entities (rather than changing the keys to orderId, orderName, userId, userName, etc.), so the developer has to pass a element context wherever there might be a clash.
As an improvement, an attribute like data-bind-prefix="user" could be added to the outer element, and a special character can be added to the bind key, such as data-bind:text="^id" to indicate that the key should be transformed to "userId", or data-bind:text="_id" for "user_id", for example.