Dynamic content - how does the "currency format" modifier work?

I’m merging a price stored in a custom field (“currency” type) into an email. If I just insert the field directly, it comes out with a single decimal and no currency symbol, like 30.0, which ain’t great.

However, when I select the field in the Dynamic Content builder tool, it offers “Currency Format” as one of the modifiers, with an empty parameters field next to it. I can’t find any documentation for what’s supposed to go in the parameters field. From testing, it seems to accept literally anything and always spits out the price formatted with a dollar sign and two cents places – i.e. all of the following give the same output despite their increasing ludicrousness:

[[ contact.custom_fields.CJMSubscriptionPrice | currency ]]
[[ contact.custom_fields.CJMSubscriptionPrice | currency: true ]]
[[ contact.custom_fields.CJMSubscriptionPrice | currency: false ]]
[[ contact.custom_fields.CJMSubscriptionPrice | currency: 42 ]]
[[ contact.custom_fields.CJMSubscriptionPrice | currency: abcdefghi ]]
[[ contact.custom_fields.CJMSubscriptionPrice | currency: "Zaphod Beeblebrox" ]]

Are there any parameter values that actually do something? I’d love a way to format with/without cents for whole-dollar amounts, for instance. (I would assume it should work something like how date fields take the custom: "YYYY" Liquid filter for formatting.)

For now I’m just using the filter without a parameter since it seems safe enough.

Hi @Andron_Ocean,

I am not an expert on the syntax, but maybe this article will help below.

https://docspring.com/docs/html_templates/liquid_filters.html

See if any of those parameters works.

currency
{{ number | currency }}

{{ number | currency: "<delimiter>", "<separator>", "<format>", "<negative_format>", "<precision>" }}
Formats a number as a currency, with grouped thousands and two decimal places (e.g. $12,324.00.)

Parameters:

unit - Sets the denomination of the currency (defaults to “$”).
delimiter - Sets the thousands delimiter (defaults to “,”).
separator - Sets the separator between the fractional and integer digits (defaults to “.”).
format - Sets the format for non-negative numbers (defaults to “%u%n”). Fields are %u for the currency, and %n for the number.
negative_format - Sets the format for negative numbers (defaults to prepending a hyphen to the formatted number given by format). Accepts the same fields than format, except %n is here the absolute value of the number.
precision - Sets the level of precision for decimal places (defaults to 2).
Examples:

{{ 1 | currency }}
=> "$1.00"

{{ 1000 | currency }}
=> "$1,000.00"

{{ 1234.56 | currency: "€", ".", ","  }}
=> "€1.234,56"

{{ -1234567890.50 | currency: "$", ",", ".", "%u%n", "(%u%n)" }}
=> ($1,234,567,890.50)

{{ 1234567890.50 | currency: "R$", "", ",", "%n %u" }}
=> 1234567890,50 R$