Getting Started
Create a file called my-report.md.jinja anywhere in your recipe folder. The editor finds templates by extension (.jinja, .j2, .jinja2), so location is up to you — a templates/ folder keeps things tidy. Start simple:
# {{ metadata.title | default("Ingredients") }}
{% for ingredient in ingredients | sort(attribute='name') -%}
- {{ ingredient.name }}{% if ingredient.quantity %}: {{ ingredient.quantity }}{% endif %}
{% endfor %}
ingredients and metadata come from whichever recipe you render against — the template is reusable across your whole collection.
Render it
Open any .cook file, run Cooklang: Render Report… from the command palette (or right-click in the recipe's source view; the preview has no such menu entry), and pick my-report.md.jinja from the list. The rendered report opens in its own tab with print and PDF/PNG export. Edit the template, render again, and iterate.
Your own data with db() — free
For facts that aren't in the recipe — densities, prices, storage times, your own nutrition numbers — keep a db/ folder in the root of your recipe folder (or config/db/). It's a directory of YAML files, one folder per ingredient; the editor picks it up automatically:
db/
├── eggs/
│ └── meta.yml
└── flour/
└── meta.yml
With db/eggs/meta.yml like:
density: 1.03
storage:
shelf life: 30
fridge life: 60
read it in a template as directory.file.key.subkey:
Density: {{ db('eggs.meta.density') }}
Shelf life: {{ db('eggs.meta.storage.shelf life') }} days
This is the save-money route: everything is plain text you maintain yourself, and it works without a subscription.
The same template renders from the command line with CookCLI's cook report. CookCLI (0.41.1) doesn't pick up db/ by itself, so pass it with -d:
cook report -t templates/my-report.md.jinja -d db Pancakes.cook
A first nutrition callCook Basic & Pro
With Cook Basic or Cook Pro and a signed-in Cook account, templates can look ingredients up in the curated nutrition database instead:
{% set n = aggregate_nutrition(ingredients) -%}
{% for item in n["items"] -%}
- {{ item.ingredient }}: {{ item.macros.kcal }} kcal, {{ item.macros.protein_g }} g protein
{% endfor %}
Total: {{ n.totals.macros.kcal }} kcal, {{ n.totals.macros.protein_g }} g protein
aggregate_nutrition() reads the quantity, unit and preparation straight off each ingredient — @salmon{150%g}(cooked) resolves as 150 g of cooked salmon — and counts an ingredient with no amount as a pinch. To look up a single ingredient there is nutrition_for(ingredient), which returns kcal, protein_g, fat_g, carb_g and fiber_g directly; it needs a numeric amount, and stops the render on an ingredient like @salt or @butter{a knob}.
If you're not subscribed, the render stops with a message telling you so — remove the nutrition calls to render the rest. Accounts from before the paywall don't have the nutrition service. Requests that templates send to it count against your nutrition API daily quota (Cook Basic 1,000 requests a day, Cook Pro 5,000); see Nutrition API.
Ready for more? The nutrition function reference covers totals, vitamins, allergens and confidence.