clj-fast-html is a Clojure library designed for fast and efficient HTML generation.
You can find the latest version on Clojars:
Here is an example of how to use clj-fast-html to generate an HTML string:
(clj-fast-html.core/to-html-string
[[:html/raw "<!DOCTYPE html>"]
[:html
[:head
[:title "Title"]]
[:body
[:h1#id.class1.class2 "Header"]
[:p {:style {:color "red"}} "text"]
[:p {:class ["class3" "class4"]} "text"]
[:p {:class "class3 class4"} "text"]
[:dialog {:open true} "text"]
(mapv
(fn [x]
[:span x])
[1 2 3 4])]]])
"<!DOCTYPE html><html><head><title>Title</title></head><body><h1 id='id' class='class1 class2'>Header</h1><p style='color:red'>text</p><p class='class3 class4'>text</p><p class='class3 class4'>text</p><dialog open>text</dialog><span>1</span><span>2</span><span>3</span><span>4</span></body></html>"
The performance of clj-fast-html is benchmarked against other popular HTML generation libraries. Below are the benchmark results for generating the Clojure home page | Library | Average (ns) | % | |------------------------|------------------|----------| | clj-fast-html (latest) | 39434.940 ns/op | 0% | | Hiccup (2.0.0-RC3) | 306147.614 ns/op | 676.34% | | Hiccup (2.0.0-RC1) | 666406.325 ns/op | 1589.89% |
To run the benchmark yourself, use the following command:
make bench
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close