TLDR: I would like an html attribute that is used as a prefix for any element in it's innerHTML.
I use jinja templates, and when i nest templates to build up a form (or replace some parts of it with HTMX) I need to pass the prefix for the json values down to the input.
However all the information is already in the html structure to infer the prefix. I would like to set the prefix on a container, then each input only specifies the last part. This makes it difficult to refactor/ make each request as local as possible.
I think this would pair very well with the whole hypermedia concept.
Example html where I use a fictional json-prefix attribute.
<form>
<div json-prefix="car">
<div json-previx="manufacturer">
<input name="location">
<input name="name">
</div>
<input name="model">
<input name="plate">
</div>
</form>
Resulting json. Observe how the various json-prefix compose with each other.
{
"car": {
"manufacturer": {
"location": ...
"name": ....
},
"model": ...
"plate": ...
}
}
Of course it would be nice to also have an opt-out flag to handle exceptions.
TLDR: I would like an html attribute that is used as a prefix for any element in it's innerHTML.
I use jinja templates, and when i nest templates to build up a form (or replace some parts of it with HTMX) I need to pass the prefix for the json values down to the input.
However all the information is already in the html structure to infer the prefix. I would like to set the prefix on a container, then each input only specifies the last part. This makes it difficult to refactor/ make each request as local as possible.
I think this would pair very well with the whole hypermedia concept.
Example html where I use a fictional
json-prefixattribute.Resulting json. Observe how the various
json-prefixcompose with each other.{ "car": { "manufacturer": { "location": ... "name": .... }, "model": ... "plate": ... } }Of course it would be nice to also have an opt-out flag to handle exceptions.