Skip to content

Instantly share code, notes, and snippets.

@hlship
Created September 18, 2011 19:09
Show Gist options
  • Save hlship/1225419 to your computer and use it in GitHub Desktop.
Save hlship/1225419 to your computer and use it in GitHub Desktop.
More complicated (defrecord) example
(defrecord Element [name attributes content]
NodeStreaming
(stream [node strategy out]
(let [element-name (clojure.core/name name)
attr-quote (strategy :attribute-quote)]
(write out "<" element-name)
; Write out normal attributes
(doseq [[attr-name attr-value] attributes]
(if-not (nil? attr-value)
(write out
" " (clojure.core/name attr-name) "=" attr-quote (to-attr-string attr-value) attr-quote)))
(if (empty? content)
((strategy :write-empty-element-close) element-name out)
(do
(write out ">")
(stream-nodes content strategy out)
(write out "</" element-name ">"))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment