I'm scratching my head on this for a while. I have this hiccup snippet:
[:div.tab-pane {:id (name (:name t))} ...]
't' is a record with, among other fields, :name
set to a keyword. This particular record has :name mapped to :testgroup
.
If I run it like this:
[:div.tab-pane {:id (:name t)} ...]
The resulting html is not surprisingly: <div id=":testgroup" class="tab-pane" .../>
But when I run it calling (name (:name t))
i get: <div class="tab-pane" .../>
This has nothing to do with hiccup, in my tests for this function I get a nil value in the {:id } map in the original [:div ...] vector , but why?
Silly mistake. In case others run into it:
What I omitted above is that the function is part of a protocol extended on that particular record. That means that the symbol
name
inside the protocol method is shadowed by thename
field of the record. Callingclojure.core/name
instead ofname
solved the problem.