From a8696e088efedf310929bc4e01eded36d41414b1 Mon Sep 17 00:00:00 2001 From: Asko Nõmm Date: Wed, 11 Feb 2026 16:48:43 +0200 Subject: Update docs --- README.md | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'README.md') 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"))]) ;;=>
hello world
``` @@ -185,6 +183,33 @@ It works seamlessly with standard Clojure functions like `map`: ;;=> "" ``` +#### 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") +;;=> "
world
" +``` + **Note for ClojureScript:** Remember to use `:refer-macros` instead of `:refer` when requiring `defhtml`. ----- -- cgit v1.2.3