0

I am using a Jinja2 macro to display a dict with values that contain HTML tags on my website:

{% macro print_res(key, value) %}

<b>{{ key|capitalize }}:</b> {{ value }}
    <br>

{% endmacro %}

When I pass the dict to the macro however, the webpage is showing the actual HTML tags like when I would like the actual text to be italicized.

Is there a way to do this?

Thank you!

1 Answers1

2

Hitting ctrl + U will allow you to see the page source. If the text that's supposed to be your HTML tags is shown as Charset Codes (i.e " ") then you'll need to use the "safe" filter when you pass the dict, like so:

{% macro print_res(key, value) %}

    <b>{{ key | capitalize | safe }}: </b> {{ value }}
    <br>

{% endmacro %}

This should tell Jinja2 not to convert the text into charsets.