Hiccup style syntax for generating HTML

Rather that write HTML code, you can use Clojure to write it for you. This provides a simpler to type syntax based on the vector in Clojure.

Instead of angle bracket < > and tags like p. you can define section using vectors [ ] and :keywords.

Examples

So for a header you would write

[:div
[:h1 "I am a header"]]

A simple piece of HTML (for web pages)

[:div
  [:h1 "This is HTML code generated by Clojure"]
  [:p "Hiccup is a simple way to write HTML in Clojure, without all those angle brackets"]
  [:a {:href "https://github.com/weavejester/hiccup"}
  "Read more about Hiccup at its Github repository"]]

We can also create HTML for displaying images

[:img
 {:src "https://avatars1.githubusercontent.com/u/9254615?v=3&s=150"}]

results matching ""

    No results matching ""