Articles in this section

Convert a multiline field value to a single line field value

This article explains how to use a handlebars expression to convert a multiline field value (like an an address) to a single line field value.

Sample data

{"Shipping Address": "Example Name\n1313 Mockingbird Lane\nSan Mateo CA 94404\nUnited States"}

In this example, the shipping address field interprets newline characters (\n) as literal newlines.

Template

{{[Shipping Address]}}

Output

Example Name
1313 Mockingbird Lane
3rd Floor
San Mateo CA 94404
United States

The jsonEncode handlebar allows you to preserve the newline characters.

Template

{{jsonEncode [Shipping Address]}}

Output

Example Name\n1313 Mockingbird Lane\nSan Mateo CA 94404\nUnited States

The replace handlebar allows you to substitute another value for the newline character. This example replaces the newline character with a comma and a space (", ").

Template

{{replace (jsonEncode [Shipping Address])"\n" ", "}}

Output

Example Name, 1313 Mockingbird Lane, San Mateo CA 94404, United States
Was this article helpful?
3 out of 3 found this helpful

Comments

0 comments

Please sign in to leave a comment.