Skip to content

feat(server): --inline-quantities shows each ingredient's quantity in the step - #832

Open
alangrainger wants to merge 1 commit into
cooklang:mainfrom
alangrainger:inline-quantities
Open

alangrainger wants to merge 1 commit into
cooklang:mainfrom
alangrainger:inline-quantities

Conversation

@alangrainger

@alangrainger alangrainger commented Nov 9, 2026 •

Copy link
Copy Markdown

Optional. Shows inline ingredients in recipe steps:

Instead of: "Bring water to a boil. Add pasta."

Shows as: "Bring 4 cups water to a boil. Add 250g pasta."

Personally I think this should be the default display. This is what attracted me to Cooklang spec in the first place, because it's so much easier to follow a recipe like this - without having to look back and forwards from the step to the amounts.

image

Adds cook server --inline-quantities (also COOK_INLINE_QUANTITIES=1, for containers). With it on, each ingredient badge inside a step carries the scaled quantity. The line under the step then lists only the ingredients that have a preparation note ("garlic (lightly smashed)"), so nothing shows twice and notes are still there.

Addresses #337. The default is unchanged: the badge shows the name and the line under the step shows the amounts. It is a server flag rather than a preference cookie, so it follows the --recipes-only pattern.

How it works:

  • FeatureFlags gains inline_quantities. The recipe page handler sets it from the server's --inline-quantities flag.
  • StepItem::Ingredient gains a label: the name, with the quantity and unit in front of it when the flag is on. The builder derives it beside the step summary line, which then keeps only noted ingredients. Scaling comes for free since the builder gets the scaled recipe.
  • templates/recipe.html renders label in the badge. Cooking mode clones the step body, so it shows the same.
  • cook build web is unaffected (the flag defaults to off there).

Tests: two unit tests in src/web/builders.rs and a Playwright spec, tests/e2e/inline-quantities.spec.ts, that starts a server with the flag. Documented in docs/server.md.

@dubadub

dubadub commented Nov 9, 2026

Copy link
Copy Markdown
Member

I was thinking to make this default replacing current view. I wasn't sure about how other languages will work and also after scaling we might need to modify words.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants