Skip to content


Subversion checkout URL

You can clone with
Download ZIP
A ClojureScript port of Hiccup - a fast library for rendering HTML in ClojureScript
tree: cc1eeb5559

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.


Hiccups is a ClojureScript port of Hiccup - an alternative to Closure Templates for representing HTML in ClojureScript. It uses vectors to represent tags, and maps to represent a tag's attributes.

The goal is to provide similar performance to Closure Templates with a much more "Clojure friendly" syntax.


Hiccups needs to be in the classpath when the ClojureScript compiler is run. If you're developing in a Leiningen project, you can just add a dependency to [hiccups "0.1.0"]. Otherwise, there are at least two options:

  1. Download the Hiccups jar and drop it in your classpath.
  2. Clone the Git repository and add src/clj and src/cljs to your classpath.

ClojureScript command line tools

While best practices for how to include external ClojureScript libraries don't really exist yet, one option is to drop the Hiccups jar in $CLOJURESCRIPT_HOME/lib. This will make Hiccups available to the command line compiler script as well as the REPL when launched via script/repl or script/repljs.


Require both the core macros and the runtime functions in your namespace declaration:

(ns myns
  (:require-macros [hiccups.core :as hiccups])
  (:require [hiccups.runtime :as hiccupsrt]))

(hiccups/defhtml my-template []      
    [:a {:href ""}


Here is a basic example of Hiccups syntax:

(html [:span {:class "foo"} "bar"])
"<span class=\"foo\">bar</span>"

The first element of the vector is used as the tag name. The second attribute can optionally be a map, in which case it is used to supply the tag's attributes. Every other element is considered part of the tag's body.

Hiccups is intelligent enough to render different HTML tags in different ways, in order to accommodate browser quirks:

(html [:script])
(html [:p])
"<p />"

And provides a CSS-like shortcut for denoting id and class attributes:

(html [ "bang"])
"<div id=\"foo\" class=\"bar baz\">bang</div>"

If the body of the tag is a seq, its contents will be expanded out into the tag body. This makes working with forms like map and for more convenient:

(html [:ul
        (for [x (range 1 4)]
          [:li x])])

See the Hiccup wiki for more information.


  • XML mode
  • Form helpers
  • Page helpers
  • Figure out if the runtime can be pulled in without an explicit require by the user
  • Explore potential performance improvements using Google's StringBuffer et al.
  • Run tests in Rhino instead of a browser?
Something went wrong with that request. Please try again.