I am displaying float values (ratings, price, etc.) and fractions in html.eex templates, and want to format the precision across different views. I don’t want to repeatedly format each instance of a variable in each template.
I would appreciate if someone would point me in the right direction for the following:
- How would I format floats across views?
- How would I format floats across an attribute? e.g., set a variable attribute or flag for :rating and :price, respectively, where :rating has Float.round(3) and :price has Float.round(2)?
- What’s the correct way to input and output fractional values? Example: input height of
6'2"and display as
6 feat 2 inchesor input length of
1' 3/8"and display as
1.375(or vice versa: input