Reputation: 2888
I have flask, jinja2 and python.
So, I'm trying to display text that is stored as markdown.
I do this
class Article(db.Entity):
...
def html(self):
return markdown(self.text) # from markdown import markdown
Next in my view I do this
html_text = article_.html()
return render_template('article.html', article=article_, comments=comments, user=user, text=html_text)
And in article.html I just have this line
{{text}}
So, with data stored in db as *im busy*
I have <p><em>im busy</em></p>
in my browser.
I tried to use .replace('<', '<').replace('>', '>')
but it changes nothing.
Upvotes: 9
Views: 6456
Reputation: 1269
Do you know safe filter?
{{text|safe}}
Passing HTML to template using Flask/Jinja2
Upvotes: 18