summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorAsko Nõmm <asko@nmm.ee>2026-02-11 16:48:43 +0200
committerAsko Nõmm <asko@nmm.ee>2026-02-11 16:48:43 +0200
commita8696e088efedf310929bc4e01eded36d41414b1 (patch)
treea2c2565f2317bd9b9271e75b9f8f740f96db6c99 /README.md
parent92e81516d217586e961228a0380fc8bfae3ea378 (diff)
Update docsv1.2.3
Diffstat (limited to 'README.md')
-rw-r--r--README.md31
1 files changed, 28 insertions, 3 deletions
diff --git a/README.md b/README.md
index 9548d42..20e8360 100644
--- a/README.md
+++ b/README.md
@@ -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`.
-----