Templates

Text Formatters, Number Formatters, and Default Values New

You can format text and numbers, and set fallback values directly in your placeholders. This helps you control how data appears in your documents without changing the source data.

Unified Syntax

All modifiers use a pipe (|) separator for easy chaining:

{{property | modifier}} {{property | modifier:argument}} {{property | modifier1 | modifier2 | default:'fallback'}}

Text Formatters

Transform text values in your documents.

Uppercase

Convert text to all capital letters.

{{firstname | uppercase}}

Example:

  • Input: john
  • Output: JOHN

Lowercase

Convert text to all lowercase letters.

{{lastname | lowercase}}

Example:

  • Input: DOE
  • Output: doe

Title Case

Capitalize the first letter of each word.

{{company | titlecase}}

Example:

  • Input: acme corporation
  • Output: Acme Corporation

Truncate

Shorten text to a specific number of characters. Adds three dots (...) at the end.

{{description | truncate:100}}

The number after truncate: is the maximum character count.

Example:

  • Input: This is a very long description that goes on and on...
  • With truncate:20: This is a very long ...
If your text is shorter than the truncate limit, it stays unchanged. No dots are added.

Number Formatters

Format numeric values as currency, percentages, ordinals, or phone numbers.

Currency

Format a number as currency with proper symbol and thousands separators.

{{amount | currency:USD}} {{revenue | currency:EUR}} {{price | currency:GBP}}

The currency code follows the ISO 4217 standard (USD, EUR, GBP, etc.).

Examples:

  • 1500 with currency:USD$1,500.00
  • 1234.56 with currency:EUR€1,234.56
Currency formatting uses your organization's locale settings to determine symbol position and number formatting (commas vs. periods).

Ordinal

Convert a number to its ordinal form (1st, 2nd, 3rd, etc.).

{{position | ordinal}} {{rank | ordinal}}

Examples:

  • 11st
  • 22nd
  • 33rd
  • 1111th
  • 2121st

Percent

Format a decimal value as a percentage.

{{rate | percent}} {{discount | percent}}

Examples:

  • 0.2525%
  • 0.0757.5%
  • 1.5150%
The percent formatter expects a decimal value. So 25% should be stored as 0.25, not 25.

Phone

Format a phone number for readability.

{{phone | phone}} {{mobile | phone}}

Examples:

  • 5551234567(555) 123-4567
  • +14155551234+1 (415) 555-1234

Image Formatters

Control the dimensions of images from HubSpot file properties in your generated documents.

Width and Height

Set custom dimensions for file properties that contain images.

{{image_property | width:200}} {{logo_file | height:150}} {{photo | width:300 | height:200}}

Parameters:

  • width: Set image width in pixels (10-2000)
  • height: Set image height in pixels (10-2000)

Examples:

  • {{company_logo | width:250}} - Sets logo width to 250px, height auto-scales
  • {{product_image | width:400 | height:300}} - Sets both width and height
  • {{headshot | height:200}} - Sets height to 200px, width auto-scales
When you set only width or height, the image maintains its aspect ratio. Setting both width and height forces exact dimensions which may distort the image.

How It Works

  1. Template Builder: Configure width and height in Step 2 when selecting a file property
  2. Placeholder Generated: The builder creates {{property | width:X | height:Y}}
  3. Document Generation: Images are embedded with your specified dimensions

Use Cases

Company Logos

{{company_logo | width:200}}

Ensure all logos appear at a consistent size regardless of source file dimensions.

Product Images

{{product_photo | width:300 | height:300}}

Create uniform image grids in catalogs or product sheets.

Profile Photos

{{contact_photo | height:150}}

Maintain consistent heights for contact profiles while preserving aspect ratio.

Image dimensions override any database-stored default dimensions. If both exist, the placeholder dimensions take priority.

Backward Compatibility

Templates created before this feature continue working without changes:

  • Old templates use database-stored dimensions (if configured)
  • New templates use placeholder syntax for dimensions
  • You can mix both approaches in the same organization

Default Values

Set a fallback value when a property is empty or missing. Use the pipe symbol followed by default:.

Using Fixed Text

Put your fallback text in quotes (single or double).

{{phone | default:'N/A'}} {{email | default:"Not provided"}}

Example:

  • If phone is empty: Shows N/A
  • If phone has a value: Shows the phone number

Using Another Property

Reference a different property as the fallback (no quotes needed).

{{company | default:firstname}}

Example:

  • If company is empty but firstname is John: Shows John
  • If both are empty: Shows nothing
Property references are helpful when you have backup fields. For example, use a nickname when the first name is missing.

Chaining Multiple Modifiers

You can combine multiple modifiers using pipes. They are applied in order from left to right.

{{name | uppercase | truncate:50 | default:'UNKNOWN CUSTOMER'}}

How it works (left to right):

  1. uppercase is applied to the value of name
  2. truncate:50 shortens the result if needed
  3. default:'UNKNOWN CUSTOMER' provides a fallback if the value is empty at any point

Examples:

  • name is john doe: Result is JOHN DOE
  • name is empty: Result is UNKNOWN CUSTOMER
{{revenue | currency:USD | default:'$0.00'}}

Syntax Options

{{firstname | uppercase}} {{phone | default:'N/A'}} {{amount | currency:EUR}} {{text | uppercase | truncate:100}}

Legacy Colon Syntax (Still Supported)

For backward compatibility, the older colon syntax still works for text formatters:

{{firstname:uppercase}} {{description:truncate:100}}

Both syntaxes can be mixed:

{{name:uppercase | default:'N/A'}}

Common Use Cases

Business Documents

Format company names consistently:

{{company | titlecase | default:'Individual Customer'}}

Contact Information

Handle missing phone numbers with formatting:

{{phone | phone | default:'No phone on file'}}

Financial Documents

Display amounts as currency:

Total: {{amount | currency:USD}} Discount: {{discount_rate | percent}}

Rankings and Positions

Show ordinal numbers:

{{position | ordinal}} Place Winner

Labels and Shipping

Ensure uppercase for postal addresses:

{{city | uppercase}}, {{state | uppercase}} {{zip}}

Product Descriptions

Keep descriptions to a readable length:

{{product_description | truncate:150}}

Frequently Asked Questions

Q: What happens if I use an unknown formatter? A: Unknown formatters are ignored. Your text appears unchanged.

Q: Can I use multiple formatters? A: Yes! Chain them with pipes: {{name | uppercase | truncate:50}}

Q: Does the formatter apply to the default value too? A: Yes. When using both formatter and default, the formatter applies to whichever value is used (the original or the default).

Q: Can I use formatters with QR codes or barcodes? A: QR codes and barcodes have their own modifiers (size and format). Text/number formatters don't apply to them, but you can use the pipe syntax for size: {{qr:property | size:200}}

Q: Can I use text formatters on file properties? A: No. File properties only support width and height formatters for controlling image dimensions. Text/number formatters are ignored for file properties.

Q: How does currency formatting handle different locales? A: The currency symbol position and number formatting (commas vs. periods) are determined by your organization's locale settings.

Q: Can I format a number that's stored as text? A: Yes, the number formatters will attempt to parse text values as numbers. Values like "1500" or "1,500" will be recognized.