remove some whitespace on rendered pages

This commit is contained in:
Lynne Megido 2020-03-01 04:07:36 +10:00
parent 451f6afeb4
commit 8b4ae13b02
Signed by: lynnesbian
GPG key ID: F0A184B5213D9F90
2 changed files with 22 additions and 22 deletions

View file

@ -1,10 +1,10 @@
{% assign tag = "h2" %} {%- assign tag = "h2" -%}
{% if page.collection == "subrecipes" %} {%- if page.collection == "subrecipes" -%}
{% assign tag = "h4" %} {%- assign tag = "h4" -%}
{% endif %} {%- endif -%}
<{{tag}}>Ingredients</{{tag}}> <{{tag}}>Ingredients</{{tag}}>
<ul> <ul>
{% for item in page.ingredients %} {% for item in page.ingredients -%}
<li>{{ item[0] }} {% if item[2] %} {{ item[2] }} of {% endif %} {{ item[1] }}</li> <li>{{ item[0] }} {%- if item[2] -%} {{ item[2] }} of {%- endif -%} {{ item[1] }}</li>
{% endfor %} {% endfor -%}
</ul> </ul>

View file

@ -2,27 +2,27 @@
layout: default layout: default
--- ---
{%- comment -%} this is a gross method of convertin "_recipes/example.md" to "example". it does it by removing the leading "_recipes/", which is simple enough, and then the trailing ".md", which is done by converting the string to an array, reversing it, turning it back into a string, removing the leading "dm." (".md" backwards), and doing the the array -> reverse -> string shuffle again. it's ugly but hey it works right {%- endcomment -%} {%- comment -%} this is a gross method of convertin "_recipes/example.md" to "example". it does it by removing the leading "_recipes/", which is simple enough, and then the trailing ".md", which is done by converting the string to an array, reversing it, turning it back into a string, removing the leading "dm." (".md" backwards), and doing the the array -> reverse -> string shuffle again. it's ugly but hey it works right {%- endcomment -%}
{% assign id = page.path | remove_first: "_recipes/" | split: "" | reverse | join: "" | remove_first: "dm." | split: "" | reverse | join: "" %} {%- assign id = page.path | remove_first: "_recipes/" | split: "" | reverse | join: "" | remove_first: "dm." | split: "" | reverse | join: "" -%}
{%- comment -%} unfortunately we have to iterate through the entire subrecipe folder twice - once to see if there are any subrecipes that apply here, and another time to put them in. thankfully we can break out of the first loop if we find a single match. i miss jinja ;u; {%- endcomment -%} {%- comment -%} unfortunately we have to iterate through the entire subrecipe folder twice - once to see if there are any subrecipes that apply here, and another time to put them in. thankfully we can break out of the first loop if we find a single match. i miss jinja ;u; {%- endcomment -%}
{% assign applicable_subrecipes = false %} {%- assign applicable_subrecipes = false -%}
{% for subrecipe in site.subrecipes %} {%- for subrecipe in site.subrecipes -%}
{% if subrecipe.parents contains id %} {%- if subrecipe.parents contains id -%}
{%- comment -%} we found one! {%- endcomment -%} {%- comment -%} we found one! {%- endcomment -%}
{% assign applicable_subrecipes = true %} {%- assign applicable_subrecipes = true -%}
{% break %} {%- break -%}
{% endif %} {%- endif -%}
{% endfor %} {%- endfor -%}
<h1>{{ page.name }}</h1> <h1>{{ page.name }}</h1>
<p> {{ page.method.size }} steps - Estimated cooking time: {{ page.time | default: "Not provided" }}</p> <p> {{ page.method.size }} steps - Estimated cooking time: {{ page.time | default: "Not provided" }}</p>
{% if applicable_subrecipes %} {%- if applicable_subrecipes %}
<h2> Subrecipes </h2> <h2> Subrecipes </h2>
{% for subrecipe in site.subrecipes %} {% for subrecipe in site.subrecipes -%}
{% if subrecipe.parents contains id %} {%- if subrecipe.parents contains id -%}
<h3>{{ subrecipe.name }}</h3> <h3>{{ subrecipe.name }}</h3>
{{ subrecipe.output }} {{ subrecipe.output }}
{% endif %} {%- endif -%}
{% endfor %} {%- endfor -%}
{% endif %} {%- endif -%}
{% include ingredients.html %} {%- include ingredients.html -%}