Hi @vincent.cantin, I know that you are into the idea of vrac a long time ago. However, I did not understand it well. I asked ChatGPT to generate an explanation of vrac, and I felt I can understand it. Can you tell me if it is correct? Also, from the explanation, it seems that it has certain potential to cowork with HTMX. Do you is it possible?
Metosin's Clojure library **Vrac** is designed for **data-first UI rendering**, emphasizing:
- ✅ **Describing UI with data**: UI components are defined using simple data structures (typically maps).
- ✅ **Separation of data and logic**: UI structure, behavior, and state management are split into composable value fragments, making the logic easier to test and reuse.
- ✅ **Separation of pure functions and renderers**: UI definitions are not tied to specific front-end implementations (like htmx, React, or HTML), but are translated into concrete UI outputs via pluggable renderers.
---
### Core Concepts
1. **Value Fragments (vf)**
- A kind of intermediate representation for describing parts of a UI (like input fields, labels, checkboxes, etc.), without being directly tied to HTML.
- These fragments can be rendered into various formats such as HTML, JSON Schema, or OpenAPI.
2. **Renderers**
- Vrac doesn't generate HTML directly. Instead, value fragments are passed to renderers (e.g., Metosin's [Vilkka]( which output the actual UI code.
3. **Declarative + Data-Driven**
- Unlike directly using Reagent or htmx to manipulate the DOM, Vrac promotes expressing UI logic as pure data, enabling better composability and reusability across contexts.
---
### Example: Defining a Form Field with Data
clojure
(require '[vrac.core :as vr])
(def my-field
{:vf/type :text
:label "Name"
:name :name
:required? true})
This fragment describes a text input field, which can be rendered as:
- An HTML `<input>`
- A property in a JSON Schema
- A parameter spec in an API definition
---
### Relation to Other Libraries
- Works well with **Vilkka** to render HTML
- Plays nicely with **reitit**, **malli**, **hiccup**, **htmx**, **tailwind**, etc.
- The goal is to move UI definition and generation from "code + template" to "data + renderer"
---
### Use Cases
- Internal business tools or form systems
- Multi-target UI generation (Web, CLI, API docs) from a single logic source
- Testable, reusable, and version-controllable UI construction
> *Vrac is designed for data-first UI rendering* ChatGPT can sometimes be like Trump, it will make things up rather than saying that he doesn't know 😅
> *Describing UI with data*: UI components are defined using simple data structures (typically maps). Wrong again. He read the tests, saw the AST and concluded based on it.
The rest of ChatGPT's output is garbage. Sorry
I will explain Vrac more once the time is right. For now, please be patient.
In theory, the DSL can compile to other implementations like HTMX.
For now I am focusing on making the DSL work on the implementation in the namespace vrac.web.
At the moment, the right way to learn how Vrac works is to look at the examples. But .. those will no longer be what the user should use once the DSL is usable.