yogthos/Selmer

Iterating over double nested structures

Open

#121 建立於 2016年4月19日

在 GitHub 查看
 (3 留言) (0 反應) (0 負責人)Clojure (670 star) (86 fork)batch import
bughelp wanted

描述

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

貢獻者指南