How to format string with line breaks for html dynamic data

Hi!

I want to format an address in an html template using the following dynamic data.

<br>Attn: {{name}}
<br>{{street_address_1}}, {{street_address_2}}
<br>{{city}}, {{state}} {{zip}}, {{country}}

However, rather than include each piece of data individually, I would rather feed sendgrid a single string that already includes line breaks, in case attributes (such as country) vary enough that I don’t want to include them at all.

So: is there a way to format an elixir string so that when it is included as dynamic data in an html template, it includes line breaks?

Phoenix.HTML — Phoenix.HTML v4.1.1 You can use this to forego the securities of automatic content encoding in templates.

2 Likes