Reputation: 1
How can I prevent t-out
from escaping my Html code?
I am trying to display an Html code on my Website. In older Odoo versions I used t-raw
and it worked fine. Now in Odoo 16 t-raw
is deprecated and t-out
is the way to go. But t-out
always escapes my code and displays it as text on my website.
This is my old code with t-raw
:
<div class="row">
<t t-raw="html_output"/>
</div>
Here is my new code with t-out
:
<div class="row">
<t t-out="html_output"/>
</div>
How can I stop t-out
from escaping my Html code?
Upvotes: 0
Views: 1465
Reputation: 47
Per Odoo 16 QWeb Templates: Advanced Markup,
By default,
out
should HTML-escape content which needs to be escaped, protecting the system against XSS
There are a number of examples in the documentation, but I don't have quite enough context from your question to know exactly which one applies, so I'll take a couple guesses.
Python: If your html_output
variable is not fields.Html, then you should change it to one in your model.
html_output = fields.Html()
JavaScript: If your html_output
variable is created in the browser, then you should wrap it in Markup.
const { Markup } = require("web.utils");
// ...in some method prior to rendering
html_output = Markup(html_output);
Upvotes: 2