How to apply multiple Replace() functionality in FreeMarker Template Language (FTL)

Scenario: In our PDF template, the user needs to replace the company address with the following changes

  1. If the company address contains a comma, then replace it with empty that is, Replace the ‘,’ with ‘ ‘.
  2. If in the company address, the country name is ‘United States’, then replace it with ‘Deutschland’

Use the following code to replace these two needs

${companyInformation.addressText?replace(',', ' ', 'r')?replace('United States', 'Deutschland')}

Leave a comment

Your email address will not be published. Required fields are marked *