summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
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`.
-----