Odoo Help


How to render variable as html in .mako?

on 11/18/13, 9:27 AM 2,553 views


If i have a ${variable}, how can I make it render as html?

For example ${variable} contains:


Then placing it in .mako like so:


Wolud produce:


Which would be rendered in report as html, and not displayed as text in the rendered pdf.

How can this be achieved?


Grover Menacho

--Grover Menacho--
WebVision Enterprise Systems
| 5 7 8
La Paz, Bolivia
--Grover Menacho--

Odoo Developer

Grover Menacho
On 11/18/13, 11:17 AM

You have to replace tags:

replace < by &lt; 
    and > by &gt;
Jaakko Komulainen
On 11/18/13, 10:23 AM

I'm not completely sure which result you are after (if neither) but you can do like this in the .mako file:

    variable = "<p>Foo</p>"
    variable2 = since this editor likes to mess with my html tags the variable2 is in pastebin here: pastebin.com/d9gbdXCb
<div>${variable}</div>    // results in: Foo

<div>${variable2}</div>  // results in: <p>Foo</p>

My intention is to place an html element which would contain style data, f.e. <p style="this: that;"></p> and etcetera. For that purpose it needs to be rendered into html entirely, not only its contents. Your example variable2 looks promising...

on 11/18/13, 10:28 AM

Ok, in that case can't you just do as: <% variable = "<p style='color:red'> Foo </p>" %>

Jaakko Komulainen
on 11/18/13, 10:41 AM

Don't you want to use <pre> and </pre> to preserve html content ?

Gregoire Huet
on 11/18/13, 2:24 PM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)


Asked: 11/18/13, 9:27 AM
Seen: 2553 times
Last updated: 3/16/15, 8:10 AM