pages how files yaml jekyll

yaml - how - jekyll variables



YAML materia delantera para Jekyll y listas anidadas. (1)

Actualizar

Este ejemplo que acabo de escribir (llamado index.html)

--- title: the example products: - top-level: Product One arbitrary: Value nested-products: - nested: Associated Product sub-arbitrary: Associated Value - nested: Another associate sub-arbitrary: with its associated value - top-level: Product Two arbitrary: Value nested-products: - nested: nested product Two sub-arbitrary: Two''s nested''s associate value - top-level: Product Three arbitrary: Value - top-level: Product Four arbitrary: SomeValue --- <!-- index.html --> <!DOCTYPE html> <html lang="en"> <head> <title>{{ page.title }}</title> </head> <body> <h4>products:</h4> <ul>{% for product in page.products %} <li>{{ product.top-level }}: {{ product.arbitrary }}{% if product.nested-products %} <ul> {% for nestedproduct in product.nested-products %} <li>{{ nestedproduct.nested }}: {{ nestedproduct.sub-arbitrary }}</li> {% endfor %}</ul> {% endif %}</li>{% endfor %} </ul> <p>Hope that answers it</p> </body> </html>

Produce esto:

<!-- index.html --> <!DOCTYPE html> <html lang="en"> <head> <title>the example</title> </head> <body> <h4>products:</h4> <ul> <li>Product One: Value <ul> <li>Associated Product: Associated Value</li> <li>Another associate: with its associated value</li> </ul> </li> <li>Product Two: Value <ul> <li>nested product Two: Two''s nested''s associate value</li> </ul> </li> <li>Product Three: Value</li> <li>Product Four: SomeValue</li> </ul> <p>Hope that answers it</p> </body> </html>

Tengo un conjunto de listas de yaml anidadas con algo como lo siguiente:

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

Puedo for item in page.products los productos sin problemas for item in page.products y puedo usar un operador lógico para determinar si existen productos anidados. Lo que NO PUEDO hacer es pasar por múltiples nested-products por iteración de top-level

He intentado usar for subitem in item y otras opciones, pero no puedo hacer que funcione, ¿alguna idea?