Skip to content

Support implicit nesting #13

Description

@WiserOrb

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions