Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Allow nil #15

wants to merge 2 commits into from

5 participants


This change will ignore nil elements in templates instead of throwing an error. This is useful if you want to put (when) clauses directly in a template, and matches the behavior of hiccup.core/html.



I need this as well.


Is this still an issue?


My guess is yes, since it hasn't been merged. I don't think the previous PR fixes that but I didn't test it.


Sorry we're really slammed right now, we do have this fixed internally and will release a fix along with some other new features soon.


Cool. I'm just starting my first ClojureScript project, and currently figuring out all the libraries I'll need :)


I put a patched version on clojars in case you need it now (I do). (matches this branch )


By the way that made me notice: the versioning # are a bit odd, I don't know if you follow semver, but 0.0.3 should be 0.3.0 instead probably.


Thanks, Max.


I know you guys are busy, but this was opened a month ago. Seems like this should have been merged by now.


I believe this has now been fixed and your test case merged in with our changes. We had a concurrent set of changes to the actual templating stuff but your test case was still useful. Thanks and sorry that took so long.

@aria42 aria42 closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 2, 2013
  1. @aiba
  2. @aiba

    allow nil data in templates

    aiba authored
This page is out of date. Refresh to see the latest.
Showing with 12 additions and 0 deletions.
  1. +3 −0  src/dommy/template.cljs
  2. +9 −0 test/dommy/template_test.cljs
3  src/dommy/template.cljs
@@ -71,6 +71,9 @@
(do (doseq [child data] (->document-fragment result-frag child))
+ (nil? data)
+ result-frag
(throw-unable-to-make-node data))))
9 test/dommy/template_test.cljs
@@ -120,3 +120,12 @@
(deftest nested-deftemplate
(is= "<ul class=\"class1\"><li>0</li><li>1</li><li>2</li><li>3</li><li>4</li></ul>"
(.-outerHTML (nested-template 5))))
+(deftest nil-in-template
+ (is= "<span></span>"
+ (.-outerHTML (template/node [:span nil])))
+ (is= "<ul><li>0</li><li>2</li></ul>"
+ (.-outerHTML (template/node [:ul (for [i (range 3)]
+ (when (even? i)
+ [:li i]))]))))
Something went wrong with that request. Please try again.