Breve-alike in Clojure
Filed under: clojure cascade breveLisp has long tended to use DSLs for HTML generation, and Clojure is no different in this regard. In fact, Breve was inspired by Stan which in turn was inspired by these Lisp DSLs.
However, I've tended to like the Breve syntax just a little better than the true s-expression DSLs:
# breve example
html [
head [
title [ 'hello, world' ]
],
body [
div ( id='main' ) [
'hello, world'
]
]
]
Clojure provides it's own approach (and Compojure provides a very similar DSL):
;; clojure prxml example
(prxml
[:html
[:head
[:title "hello, world"]
]
[:body
[:div {:id "main"}
"hello, world"
]
]
]
)
Overall, they are quite similar in approach, but the Lisp-like bracket placement continues to disturb me slightly, and I suspect it will disturb my designer (whom I got to eventually love Breve) even more.
Today I was researching Clojure stuff built around Ring and came across Cascade. Cascade includes its own variant of this type of DSL and it's a nice cross between the traditional Lispy s-expression approach and that used by Breve:
(defview index
[env]
:html [
:head [
:title [ "hello, world" ]
]
:body [
:div { :id "main" } [
"hello, world"
]
]
]
)
This is pretty subjective, but I find the bracket placement a bit easier on the eyes and brain.






