<div class="accordion"> <ul> <li><a href="#">One</a> <ul> <li><a href="#">A</a></li> <li><a href="#">B</a> <ul> <li><a href="#">Sub A</a></li> </ul> </li> </ul> </li> </ul> </div>
And I want to map this to the following data:
(def app-state (atom {;; App Depth Tree "One" { "A" { "Sub A" nil "Sub B" nil "Sub C" nil} "B" { "Sub A" nil "Sub B" nil "Sub C" nil} "C" { "Sub A" nil "Sub B" nil "Sub C" nil}} "Two" { "A" { "Sub A" nil "Sub B" nil "Sub C" nil} "B" { "Sub A" nil "Sub B" nil "Sub C" nil} "C" { "Sub A" nil "Sub B" nil "Sub C" nil}}}))
I just can't wrap my head around how to create a (defsnippet)
that would be able to continue nesting indefinitely based on the nesting in that map.
Should I build this piece directly with om or am I missing a fundamental piece of logic?
<div class="accordion"> <ul> <li class="with-sub"><a href="#">One</a> <ul> <li class="without-sub"><a href="#">A</a></li> <li><a href="#">B</a> <ul> <li><a href="#">Sub A</a></li> </ul> </li> </ul> </li> </ul> </div>
(defn get-subs [[ky children]]
(if (empty? children)
(without-sub ky)
(with-sub ky children)))
(defsnippet with-sub "path.html" [:.sub-level] [ky children]
{[:li :> :a] (content ky)
[:li :> :ul] (content (map get-subs children))})
(defsnippet without-sub "path.html" [:.sub-level] [ky children]
{[:li :> :a] (content ky)})