4

I try to achieve to have a new line (carriage return) in the string result, but so far, I don't get this working.

This example just ignores the '\n'.

<t t-set="foo" t-value="foo_A+'\n'+foo_B"/>
ssstofff
  • 638
  • 1
  • 10
  • 19

2 Answers2

2
  1. \n is working
  2. add CSS "white-space: pre-wrap" to the element that contains this string value
ssstofff
  • 638
  • 1
  • 10
  • 19
2

You can use:

<t t-set="foo" t-value="foo_A+'&lt;br/&gt;'+foo_B"/>

Then, when you actually print that:

<t t-raw="foo"/>

But beware when doing this if variables come from untrusted sources, they could inject malicious code. Possibly a more secure alternative would be:

<t t-esc="foo_A"/><br/><t t-esc="foo_B"/>
Yajo
  • 5,808
  • 2
  • 30
  • 34