jekyll - How can I loop on all items where a certain field is not empty? -


i want loop on items in collection have field set (not empty). tried this:

{% assign papers_with_demos=site.data.papers | where:"demo", not blank %} {% if papers_with_demos.size > 0 %}    <h2>demos</h2>    {% paper in papers_with_demos %}]    ...     {% endfor %} {% endif %} 

but not work; papers returned.

my goal heading "demos" shown, if there 1 or more paper demo.

if papers being returned, must using data files. if value empty particular key in data file return false. check data key forloop like:

{% paper in site.data.papers %}   {% if paper.demo %}     {% endif %} {% endfor %} 

you'll find more info in data files section of jekyll documentation.

updated in response reply:

{% item in site.data.items %}   {% if item.random %}   {% assign random-val = item.random %}     {% if random-val %}     <p>true</p>     {% endif %}   {% endif %} {% endfor %} 

this return true if inside items.yml, have - random: true, nothing if empty.


Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -