Hiccups is a ClojureScript port of the Hiccup HTML generation library. 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.
- In ClojureScript, macros need to be defined in separate Clojure namespaces. Because of this,
core functionality is split into two files:
core.clj
contains the macros and compile-time only functions, andruntime.cljs
contains functions that are also available at runtime. The contents ofruntime.cljs
are also used at compile-time, so the goal is to keep it portable between ClojureScript and Clojure. - Unit tests are run in a PhantomJS browser using lein-cljsbuild and Closure's testing libs.
- Not everything has been ported yet. See ToDo.
- Crate is an alternative Hiccup style library for ClojureScript. The main difference
between Crate and Hiccups is that Crate generates DOM nodes and Hiccups generates strings. There are a few reasons why you might consider Hiccups over Crate (YMMV, of course):
- As with the original Hiccup, Hiccups tries to do as much as possible at compile time, with macro expansion.
- Working with strings can be much more performant than working with DOM nodes, especially with large amounts of markup, and especially with older browsers.
- Easier to use in headless environments like Node.js
- Closure Templates is Google's Closure templating library.
Add the following dependency to your project.clj
file:
[hiccups "0.3.0"]