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
Say you wanted to format a dollar amount with tempo.js. You'd do something like this:
{{cost | format | prepend $ }}
However, if you have cents in your dollar amount, it will not be formatted in the traditional way. To be specific: if cost=float(12.10), then the above template would yield "$12.1". This does not match the desired output of "$12.10".
I propose that the format filter's syntax be extended to take up to two optional arguments. The first argument would be the number of digits that must be shown on the left of the decimal point, and the second argument would be the number of digits that must be shown on the right of the decimal point.
Some examples with cost=12.1:
{{ cost | format }} : 12.1
{{ cost | format 4 }}: 0012.1
{{ cost | format 0,2}}: 12.10
{{ cost | format 4,2}}: 0012.10
A complete template for formatting dollar amounts if this feature is implemented would be:
{{ cost | format 0,2 | prepend $ }}
The text was updated successfully, but these errors were encountered:
Say you wanted to format a dollar amount with tempo.js. You'd do something like this:
{{cost | format | prepend $ }}
However, if you have cents in your dollar amount, it will not be formatted in the traditional way. To be specific: if cost=float(12.10), then the above template would yield "$12.1". This does not match the desired output of "$12.10".
I propose that the format filter's syntax be extended to take up to two optional arguments. The first argument would be the number of digits that must be shown on the left of the decimal point, and the second argument would be the number of digits that must be shown on the right of the decimal point.
Some examples with cost=12.1:
{{ cost | format }} : 12.1
{{ cost | format 4 }}: 0012.1
{{ cost | format 0,2}}: 12.10
{{ cost | format 4,2}}: 0012.10
A complete template for formatting dollar amounts if this feature is implemented would be:
{{ cost | format 0,2 | prepend $ }}
The text was updated successfully, but these errors were encountered: