From 8b4ae13b0227a34cf793faa8830e3665d4b48a81 Mon Sep 17 00:00:00 2001 From: Lynne Date: Sun, 1 Mar 2020 04:07:36 +1000 Subject: [PATCH] remove some whitespace on rendered pages --- _includes/ingredients.html | 14 +++++++------- _layouts/recipe.html | 30 +++++++++++++++--------------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/_includes/ingredients.html b/_includes/ingredients.html index 16d1c67..53efde5 100644 --- a/_includes/ingredients.html +++ b/_includes/ingredients.html @@ -1,10 +1,10 @@ -{% assign tag = "h2" %} -{% if page.collection == "subrecipes" %} - {% assign tag = "h4" %} -{% endif %} +{%- assign tag = "h2" -%} +{%- if page.collection == "subrecipes" -%} + {%- assign tag = "h4" -%} +{%- endif -%} <{{tag}}>Ingredients diff --git a/_layouts/recipe.html b/_layouts/recipe.html index 9534880..08492a4 100644 --- a/_layouts/recipe.html +++ b/_layouts/recipe.html @@ -2,27 +2,27 @@ 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 -%} -{% 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 -%} -{% assign applicable_subrecipes = false %} -{% for subrecipe in site.subrecipes %} - {% if subrecipe.parents contains id %} +{%- assign applicable_subrecipes = false -%} +{%- for subrecipe in site.subrecipes -%} + {%- if subrecipe.parents contains id -%} {%- comment -%} we found one! {%- endcomment -%} - {% assign applicable_subrecipes = true %} - {% break %} - {% endif %} -{% endfor %} + {%- assign applicable_subrecipes = true -%} + {%- break -%} + {%- endif -%} +{%- endfor -%}

{{ page.name }}

{{ page.method.size }} steps - Estimated cooking time: {{ page.time | default: "Not provided" }}

-{% if applicable_subrecipes %} +{%- if applicable_subrecipes %}

Subrecipes

- {% for subrecipe in site.subrecipes %} - {% if subrecipe.parents contains id %} + {% for subrecipe in site.subrecipes -%} + {%- if subrecipe.parents contains id -%}

{{ subrecipe.name }}

{{ subrecipe.output }} - {% endif %} - {% endfor %} -{% endif %} + {%- endif -%} + {%- endfor -%} +{%- endif -%} -{% include ingredients.html %} +{%- include ingredients.html -%}