Hi

On 5/19/24 12:39, Robert Landers wrote:
In general, it would be nice to have some proper inline string
templating, like other languages (js, C#, etc). At least some way to
evaluate an expression and format. I'm thinking like in C#:

$"Price: {price:C2}, Quantity: {quantity}, Discount: {discount:P1},
Total after discount: {(price * quantity * (1 - discount)):N2}"

Price is formatted using currency with 2 decimal places, discount is
formatted using percentage and one decimal, and N is a number format
with 2 decimals.

While I can get behind allowing arbitrary expressions for ease of use, the formatting suffixes you suggested effectively replicate what `sprintf` already does for you, just with an "incompatible syntax".

In fact for proper number and currency formatting you would likely need intl's MessageFormatter anyways, which already supports those kind of placeholders in a standardized fashion.

Best regards
Tim Düsterhus

Reply via email to