You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Server: custom metadata with a number or true/false value is not shown on the recipe page #838
The recipe page shows unknown front-matter keys as key: value pills, but only when the value is text. A key whose value is a number or true/false is left out, with no warning. cook recipe in the terminal prints all of them.
Shown:🥗 vegan and rated: 4/5 (YAML reads 4/5 as text).
Not shown:rating, year, oven temperature, tested.
cook recipe prints all five custom keys.
Seen with 0.38.1 (rating: 4 and rating: 4.5 not shown, rating: 4/5 and rating: "★★★★☆" shown). The code is the same on main (v0.41.1); year, oven temperature and tested above follow from the code and were not run.
Cause
src/web/builders.rs builds the custom pills from string values only, in both places:
recipe page: if let (Some(key_str), Some(val_str)) = (key.as_str(), value.as_str())
menu page: .filter_map(|(key, value)| Some((key.clone(), value.as_str()?.to_string())))
The get_field closure a few lines above already turns a string, an integer or a float into text for the standard keys.
Expected
A custom key with a number or boolean value gets the same key: value pill as a text value, with numbers formatted as get_field formats them (4, 4.5).
Lists and mappings are a separate matter, covered by #459.
Context
Found while answering a question about showing a recipe rating. A canonical rating key is proposed in cooklang/spec#164; this bug is independent of it and affects any numeric custom key.
Activity