1

When I try to render a string variable in mako template like: ${ variable_name } As, the variable contains html content, the content is not rendered properly. Rather than displaying HTML, the output just displays the source code like:

<div>...<p>..</p>...</div>

But the HTML directly written in MAKO renders correctly. Imean

var = <p>Not Rendering HTML</p>
Line 1:  <p>Testing line</p>
Line 2:  ${var}

Line1 renders as: Testing line

But line 2 renders as: <p>Not Rendering HTML</p>

What should I do...?

Surreal Dreams
  • 26,055
  • 3
  • 46
  • 61
athultuttu
  • 192
  • 3
  • 15

1 Answers1

7

Try outputting your variable with a n filter, like so:

${var | n}

This should disable all default filtering. You can read more about filtering here: http://docs.makotemplates.org/en/latest/filtering.html

You may also want to look at this question and its answers: Mark string as safe in Mako

Community
  • 1
  • 1
Surreal Dreams
  • 26,055
  • 3
  • 46
  • 61