YAML front matter for Jekyll and nested lists
Date : March 29 2020, 07:55 AM
wish of those help I have a set of nested yaml lists with something like the following: , Update This example I just wrote (called 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>
<!-- 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>
|
Jekyll YAML file with nested elements
Date : March 29 2020, 07:55 AM
I wish did fix the issue. 1. your datas file is wrong you have overlapping entries for locales.en and locales.fr. Correct nesting can be : locales: games:
en:
title: "Games"
detail: "To relax and take breaks during the day, we play football, table tennis and Xbox"
icon: benefit1.png
fr:
title: "Jeux"
detail: "To relax and take breaks during the day, we play football, table tennis and Xbox"
icon: benefit1.png
drink:
en:
title: "Drink"
detail: "The fridge is full of beer cans and Coca-Cola, Ice Tea and coffee. You can drink whatever makes you happy, all day!"
icon: benefit2.png
fr:
title: "Boissons"
detail: "The fridge is full of beer cans and Coca-Cola, Ice Tea and coffee. You can drink whatever makes you happy, all day!"
icon: benefit2.png
benefit = Array
["en",{"title"=>"Drink", "detail"=>"The fridg...!", "icon"=>"benefit2.png"}]
{% for benefit in site.data.benefit.locales.games %}
<div class="s-column6">
<div class="kiwup-benefit pb1 mb1">
<img src="/image/benefit/{{ benefit[1].icon }}" alt="kiwuper">
<div class="kiwup-benefit-info">
<h3 class="h4-like text-dark">{{ benefit[1].title }}</h3>
<p>{{ benefit[1].detail }}</p>
</div>
</div>
</div>
{% endfor %}
|
Looping through nested image gallery array in Jekyll/YAML
Date : March 29 2020, 07:55 AM
hop of those help? Why can't I loop through the main: image array for this project group in Jekyll? , It was an issue with your looping. {% for project in navigation.project %}
{% for image in project.main %}
<!-- This loop needed to loop within its parent -->
{% endfor %}
{% endfor %}
{% for item in site.data.navigation %}
<ul>
<li>
<p style="border: solid 1px red;">Project loop {{ forloop.index }}</p>
{% for project in item.project %}
<ul>
<li>
<p style="border: solid 1px green;">Sub Loop {{ forloop.index }}</p>
<ul>
<li style="border: solid 1px blue;">
<p><strong>categ:-</strong> {{project.categ}}</p>
</li>
<li style="border: solid 1px blue;">
<p><strong>name:-</strong> {{project.name}}</p>
</li>
<li style="border: solid 1px blue;">
<p><strong>age:-</strong> {{project.age}}</p>
</li>
<li style="border: solid 1px blue;">
<p><strong>feeling:-</strong> {{project.feeling}}</p>
</li>
<li style="border: solid 1px blue;">
<p><strong>thumbnail:-</strong> {{project.thumb}}</p>
</li>
<li>
<ol>
{% for image in project.main %}
<li style="border: solid 1px purple;">
<p>{{ image.image }}</p>
</li>
{% endfor %}
</ol>
</li>
</ul>
</li>
</ul>
{% endfor %}
</li>
</ul>
{% endfor %}
<div style="border: solid 4px purple; padding: 10px;">
{% for item in site.data.navigation %}
<div style="border: solid 3px red; padding: 10px; margin: 10px;">
<pre>LOOP {{ forloop.index }}</pre>
{% for project in item.project %}
<div style="border: solid 2px green; padding: 10px; margin: 10px;">
<pre>SUB LOOP {{ forloop.index }}</pre>
{% for image in project.main %}
<div style="border: solid 1px blue; padding: 10px; margin: 10px;">
<pre>IMAGE {{ forloop.index }}</pre>
</div>
{% endfor %}
</div>
{% endfor %}
</div>
{% endfor %}
</div>
- project:
-
categ: navigation
name: Letterman
age: 54
feeling: swell
thumb: thumb-letterman.jpg
main:
- image: image_1.jpeg
- project:
-
categ: navigation
name: Carlin
age: 67
feeling: nice
thumb: thumb-carlin.jpg
main:
- image: image_1.jpeg
- image: image_2.jpeg
- image: image_3.jpeg
|
Access nested config variables in a rule
Date : March 29 2020, 07:55 AM
it fixes the issue One way to solve it is by using params and resolving the variable outside the shell block. rule simgenome:
input:
"human.order6.mm",
output:
"{family}-refr.fa.gz"
params:
seed=lambda w: config[w.family]['seeds']['genome'],
numseqs=lambda w: config[w.family]['numchr'],
seqlen=lambda w: config[w.family]['chrlen']
shell:
"nuclmm simulate --out - --order 6 --numseqs {params.numseqs} --seqlen {params.seqlen} --seed {params.seed} {input} | gzip -c > {output}"
|
is possible to loop through yaml variables of jekyll page without knowing them?
Date : March 29 2020, 07:55 AM
hop of those help? When you loop on a Page (Page objects like index, about, ...) variables, you receive arrays like : {% for var in page %}
{{ var | inspect }} => ["layout", "default"]
{% for var in page %}
key-name : {{ var[0] }} , value : {{ var[1] }}
{% endfor%}
{% for var in page %}
key : {{ var }} , value : {{ page[var] }}
{% endfor%}
|