diff options
| author | Asko Nõmm <asko@nmm.ee> | 2026-02-11 16:48:43 +0200 |
|---|---|---|
| committer | Asko Nõmm <asko@nmm.ee> | 2026-02-11 16:48:43 +0200 |
| commit | a8696e088efedf310929bc4e01eded36d41414b1 (patch) | |
| tree | a2c2565f2317bd9b9271e75b9f8f740f96db6c99 /README.md | |
| parent | 92e81516d217586e961228a0380fc8bfae3ea378 (diff) | |
Update docsv1.2.3
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 31 |
1 files changed, 28 insertions, 3 deletions
@@ -144,9 +144,7 @@ You can also use fragment nodes, which are nodes with a name of `:<>` and whose (:require [dompa.nodes :refer [$ ->html]])) (->html [($ :button - ($ :<> - ($ "hello ") - ($ "world")))]) + ($ :<> "hello " "world"))]) ;;=> <div>hello world</div> ``` @@ -185,6 +183,33 @@ It works seamlessly with standard Clojure functions like `map`: ;;=> "<ul><li>john</li><li>mike</li><li>jenna</li></ul>" ``` +#### Docstrings + +`defhtml` supports optional docstrings, just like `defn`: + +```clojure +(defhtml about-page + "Renders the about page for a person." + [who] + ($ :div "Hello, " who "!")) +``` + +#### Composition + +Functions created with `defhtml` can be nested and composed with each other: + +```clojure +(defhtml greeting [who] + ($ :span who)) + +(defhtml page [who] + ($ :div + (greeting who))) + +(page "world") +;;=> "<div><span>world</span></div>" +``` + **Note for ClojureScript:** Remember to use `:refer-macros` instead of `:refer` when requiring `defhtml`. ----- |
