我有一组嵌套的 yaml 列表,如下所示:
title: the example
image: link.jpg
products:
- top-level: Product One
arbitrary: Value
nested-products:
- nested: Associated Product
sub-arbitrary: Associated Value
- top-level: Product Two
arbitrary: Value
- top-level: Product Three
arbitrary: Value
我可以毫无问题地遍历产品,for item in page.products
并且我可以使用逻辑运算符来确定是否存在嵌套产品 - 我不能做的是在nested-products
每次迭代中循环多次top-level
我已经尝试过使用for subitem in item
和其他选项 - 但我无法让它工作 - 有什么想法吗?