more elobroated example
This commit is contained in:
parent
517636926c
commit
a92da582c2
1 changed files with 17 additions and 11 deletions
16
README.md
16
README.md
|
@ -28,15 +28,18 @@ If you don't want to import all symbols, see [H Macro](#h-macro), which provide
|
|||
(html
|
||||
(head
|
||||
(link :rel "...")
|
||||
(script :src "...")
|
||||
(script :src "..."))
|
||||
(body
|
||||
(div :id "a" :class "b"
|
||||
(p :style "color: red"
|
||||
"Some text")
|
||||
"Some text in div"))))
|
||||
"Some text in div"
|
||||
(img :src "/img/dog.png")
|
||||
(a '(:href "/cat")
|
||||
(img '((:src . "/img/cat.png")))))))
|
||||
```
|
||||
|
||||
These `html`, `div`, etc. are just functions. Element attribute can be given inline as the above example, or as alist/plist/attrs object as the first argument in the case they're calculated programmatically.
|
||||
These `html`, `div`, etc. are just functions. Element attribute can be given inline as the above example, or as alist/plist/attrs object as the first argument, like the last `a` and `img` in the above example. In this case they can be variables that calculated programmatically.
|
||||
|
||||
The remaining argument will be recognized as the children of this element. Each child can be:
|
||||
1. string;
|
||||
|
@ -122,12 +125,15 @@ Then just wrap `h` for all html generation part. In the same examples above, it
|
|||
(h (html
|
||||
(head
|
||||
(link :rel "...")
|
||||
(script :src "...")
|
||||
(script :src "..."))
|
||||
(body
|
||||
(div :id "a" :class "b"
|
||||
(p :style "color: red"
|
||||
"Some text")
|
||||
"Some text in div")))))
|
||||
"Some text in div"
|
||||
(img :src "/img/dog.png")
|
||||
(a '(:href "/cat")
|
||||
(img '((:src . "/img/cat.png"))))))))
|
||||
|
||||
(define-element dog (id size)
|
||||
(if (and (realp size) (> size 10))
|
||||
|
|
Loading…
Reference in a new issue