ChecksCook Pro
Checks turn a report from a readout into a verdict: does this recipe or week actually hit the targets? Import the built-in ck macro library once, then assert. Each macro prints a pass/fail line and records the result for the summary.
{% import "ck" as ck %}
{% set t = macros(ingredients) %}
{{ ck.range(t.kcal, client.targets.energy_kcal, "Daily kcal") }}
{{ ck.min(t.protein_g, client.targets.protein_g, "Protein (g)") }}
{{ ck.max(t.sat_fat_g, client.targets.sat_fat_g, "Saturated fat (g)") }}
| Macro | Asserts |
|---|---|
ck.min(value, target, label) | value ≥ target.min |
ck.max(value, target, label) | value ≤ target.max |
ck.range(value, target, label) | target.min ≤ value ≤ target.max |
ck.within(value, target, label) | value within target.tol_pct% of target.max |
ck.between(value, lo, hi, label) | lo ≤ value ≤ hi |
ck.absent(ingredient) | the excluded ingredient is not present |
Defining targets
In the editor, define targets at the top of the template with set — they're just data, and keeping them in the template means the whole report stays one self-contained file:
{% set client = {
"exclusions": ["peanut", "shellfish"],
"targets": {
"energy_kcal": {"min": 1800, "max": 2200},
"protein_g": {"min": 75},
"sat_fat_g": {"max": 20, "tol_pct": 10},
"fiber_g": {"min": 25}
}
} %}
{% import "ck" as ck %}
{% set t = macros(ingredients) %}
{{ ck.range(t.kcal, client.targets.energy_kcal, "Daily kcal") }}
{{ ck.min(t.protein_g, client.targets.protein_g, "Protein (g)") }}
{% for ex in client.exclusions %}{{ ck.absent(ex) }}{% endfor %}
Exclusions flag exact ingredients. For allergen-class flagging (milk, gluten, …) use the allergen summary instead.
Working from the command line or the API, you can also keep targets in separate client profile YAML files and reuse them across reports — see the developer guides.
The summary line
**Summary:** {{ all_checks() | selectattr("ok") | list | length }} of {{ all_checks() | length }} checks passed.
all_checks() returns every recorded check as {label, ok}; failed_checks() returns only the failures, handy for an "attention needed" section at the top of a report.