make amounts more readable (1.0 -> 1)
This commit is contained in:
parent
f813ae5ac3
commit
59f80f6619
2 changed files with 8 additions and 1 deletions
|
@ -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()
|
||||
|
|
|
@ -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)}}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue