make amounts more readable (1.0 -> 1)

This commit is contained in:
Emi Vasilek 2023-11-05 12:11:53 +01:00
parent f813ae5ac3
commit 59f80f6619
2 changed files with 8 additions and 1 deletions

View file

@ -278,6 +278,13 @@ class Builder:
loader=jinja2.FileSystemLoader("templates"),
autoescape=jinja2.select_autoescape(),
)
def numprint(input: int) -> str:
out = str(input)
if out.endswith(".0"):
return out.split(".")[0]
return out
self.jinjaenv.filters['numprint'] = numprint
self.ctx = Context()
# list of output files that will be built
self.outfiles: Set[str] = set()

View file

@ -1,6 +1,6 @@
{% extends "base.html" %}
{% macro ingredientpart(ing) -%}
{{ing.amount}} {{ing.unit.name}} {{ ing.name }}
{{ing.amount|numprint}} {{ing.unit.name}} {{ ing.name }}
{%- endmacro %}
{% macro ingredient(ing) -%}
{{ingredientpart(ing)}}