Debian Codegraph @

doc/_includes/examples/conditionals.jsonnet

raw
1 local Mojito(virgin=false, large=false) = {
2 // A local next to fields ends with ','.
3 local factor = if large then 2 else 1,
4 // The ingredients are split into 3 arrays,
5 // the middle one is either length 1 or 0.
6 ingredients: [
7 {
8 kind: 'Mint',
9 action: 'muddle',
10 qty: 6 * factor,
11 unit: 'leaves',
12 },
13 ] + (
14 if virgin then [] else [
15 { kind: 'Banks', qty: 1.5 * factor },
16 ]
17 ) + [
18 { kind: 'Lime', qty: 0.5 * factor },
19 { kind: 'Simple Syrup', qty: 0.5 * factor },
20 { kind: 'Soda', qty: 3 * factor },
21 ],
22 // Returns null if not large.
23 garnish: if large then 'Lime wedge',
24 served: 'Over crushed ice',
25 };
26
27 {
28 Mojito: Mojito(),
29 'Virgin Mojito': Mojito(virgin=true),
30 'Large Mojito': Mojito(large=true),
31 }