APIs & Integrations

jmci
Member

Format Numbers With Thousands Separators

I have created a new email module via the design tools. Within that module, I have created a field name starting_price that is configured as a number. I'd like to use said field in the HTML/Hubl with thousands separators.

When someone uses this module when creating a new marketing email, they are asked enter starting price but the number is not formatted with thousands separators. For example, if the price is $1,899, the user enters 1899 in the email field form (HubSpot adds the comma in the starting price input form field), but it's also being displayed as 1899 in the email template.

I'd like to format the number to be formatted with thousands separators without asking the user to enter a string in the form input.

Thoughts?

Thanks!

0 Upvotes
4 Replies 4
John
Top Contributor | Platinum Partner
Top Contributor | Platinum Partner

Format Numbers With Thousands Separators

Unfortunately no easy way to do this other than combining the format_currency and replace filters (kinda feel like there should be a format_number filter)

{{ my_number|format_currency('en-US')|replace('$', '') }}

 



I like kudos almost as much as cake – a close second.

Riadhoq
Member

Format Numbers With Thousands Separators

For anyone who's still looking for the solution.

 

Hubl has some filters available: you can use format_currency("en-US") for thousand separator. It'll also add a "$" sign in front of the number.

if item.price = 2500

Ex:  {{ item.price | format_currency("en-US") }} ==> output $2,500

 

https://designers.hubspot.com/docs/hubl/hubl-supported-filters#format-currency

0 Upvotes
jmci
Member

Format Numbers With Thousands Separators

Any ideas or suggestions?

0 Upvotes
PaulAxonGarside
Participant | Diamond Partner
Participant | Diamond Partner

Format Numbers With Thousands Separators

I think you'll have to go the string option. Ideally you'd store the number in the DB without the formatting and apply the formatting in the template.