[WICG/webcomponents] agAST: A counter-proposal to dom-parts? (Issue #1106)

conartist6 created an issue (WICG/webcomponents#1106)

I read Justin's recent [blog post about a DOM templating API](https://justinfagnani.com/2025/06/30/what-should-a-dom-templating-api-look-like), and I wanted to chime in on the discussion because I've been researching this topic quietly on my own for several years now.

While the DOMParts solution solves the problem but only when HTML is the thing being templated, I've built a document system called agAST which solves the problem for any and every possible language that you could want to template at the same time**. You get a solution to the problem that works for HTML, JS, CSS, JSON, XML, GraphQL, JSX, Python, Java... you get the idea, it works for anything.

Here is what this looks like for JS:

```js
let tree = js`fire('event', js.Expr`true`)`;

// We can always print the textual tree as if this was just a text interpolation
printSource(tree) === `fire('event', true)` // true

// We can also support random named reads (and writes) in logn time
printSource(tree.get(['statements', 0, 'callee'])) === `fire` // true
```

This works because `tree` is an immutable collections of plain JS objects and arrays -- structured more or less as a marriage of a syntax tree and a btree.

Is this interesting to the web components team? If an API like this was in common use across the ecosystem, would it have any impact on what an optimal DOM-parts design would look like?

-- 
Reply to this email directly or view it on GitHub:
https://github.com/WICG/webcomponents/issues/1106
You are receiving this because you are subscribed to this thread.

Message ID: <WICG/webcomponents/issues/1106@github.com>

Received on Wednesday, 2 July 2025 17:12:45 UTC