yogthos/Selmer

Iterating over double nested structures

Open

#121 aperta il 19 apr 2016

Vedi su GitHub
 (3 commenti) (0 reazioni) (0 assegnatari)Clojure (86 fork)batch import
bughelp wanted

Metriche repository

Star
 (670 star)
Metriche merge PR
 (Merge medio 39m) (4 PR mergiate in 30 g)

Descrizione

Hi

I have the following structure, passed to Selmer as variable 'res':

[ { :a "A1"
    :b "B1"
     :c [{ :aa "AA1"
            :bb "BB1"
            :cc "CC1"}
          { :aa "AA2"
            :bb "BB2"
            :cc "CC2"}
          { :aa "AA3"
            :bb "BB3"
             :cc "CC3"}]}
    {:a "A2"
     :b "B2"
      :c [{ :aa "AA11"
             :bb "BB11"
             :cc "CC11"}
           { :aa "AA21"
             :bb "BB21"
             :cc "CC21"}
          { :aa "AA31"
            :bb "BB31"
             :cc "CC31"}]}]

I want to iterate over the items in the first vector and print them out, and when getting to the ':c' fields I want to then start an inner iteration to print out the contents.

At the moment it is possible to get to every element in the structure with dotted notation. However, when I introduce an iterator using {% for n in res %} I then can not repeat this for the inner vector. Is this a lacking feature or am I not seeing the bigger picture? Thanks

Guida contributor