Linked Questions
85 questions linked to/from Passing HTML to template using Flask/Jinja2
38 votes
1 answer
71k views
How to replace a string with linebreaks in Jinja2 [duplicate]
I have some data in jinja2 like this 'item1|item2|item3' And I want to turn it into rendered linebreaks. However, when I replace it with br/ tags, I get the br tags rendered on the page. So {{ '...
23 votes
2 answers
29k views
How to render html content with jinja using flask? [duplicate]
I'm using Flask in an app that render some data from a sqlite database. My problem is when the app render some text that has html inside, appear as text instead of html. For example, the record in ...
21 votes
1 answer
23k views
render html strings in flask templates [duplicate]
I'm building a web page to show articles. In my database, I have to attributes, one of which is used to put Markdown code and the other to save HTML code converted from the Markdown code. I want to ...
4 votes
1 answer
10k views
jinja2 to post dataframe tables on web [duplicate]
I am using Flask ,Jinja2 template(html file) to post the panda dataframe tables which are stored in results in ABC.py. Table looks like :Image I am using dictionary to print it but it is not coming ...
11 votes
2 answers
21k views
why to use " | safe" in jinja2 Python [duplicate]
I am following a Flask tutorial where he is using " | safe " in jinja2 template. Why do we need this pipe symbol and safe? without using safe it prints all html tags. By using | safe, it shows ...
7 votes
1 answer
10k views
Render HTML tags from variable without escaping [duplicate]
I have some HTML content that I want to pass to the template to render. However, it escapes the tags to use HTML entities (<), so they show up as code rather than markup. How can I render ...
4 votes
2 answers
21k views
How to render html for variables in Flask render_template [duplicate]
I am using Flask render_template method to render my html page as below: render_template('index.html', content="<div>Hello World!</div>") My index.html is: <html lang="en&...
3 votes
2 answers
12k views
how can I load svg file into my python flask page? [duplicate]
So I want to put an svg file into my page(not as an image, as an xml element) - need it like this so I could dynamically change elements within the page. and I made a simple code that I thought it'...
3 votes
2 answers
4k views
Inserting HTML code with Flask [duplicate]
Currently I have this code boldtext = "<b>I'm bolded!<b>" @app.route('/') def index(): return render_template("index.html", boldtext=boldtext) and then in my index.html, I have a ...
2 votes
1 answer
8k views
return html code from python script to html via flask (theory)) [duplicate]
I am just playing with python script (test.py) there is one function test1(). def test1(): return '<button (code ... for one simple button) .... ></button>' In my init.py: from ...
3 votes
1 answer
3k views
Jinja2 messes up less than and greater than chars [duplicate]
So in Jinja2 I have this code: <div id='posts'> <!-- Display all posts --> {% for p in posts %} <div class='post'> <h3>{{ p[1] }}</h3> ...
-1 votes
1 answer
3k views
Rendering newline in text for a div when working with Flask as the backend? [duplicate]
I am using Flask as the backend and reading a piece of text from a file that contains newlines as \n. I wish to render this text inside a div. To do so, I am replacing the \n with <br> and then ...
-1 votes
2 answers
4k views
how to display html data stored in jinja2 variable [duplicate]
I have a variable in my python flask application, which contains html data html_data='<p> this data to be displayed </p>' I have passed this variable in render_template(temp.html,data=...
0 votes
1 answer
2k views
Flask producing HTML table as a string, not a table (Python 2) [duplicate]
I am seeing a strange issue when I attempt to write some data to a HTML table, using Flask. When the page loads, it is printing the data into a single long string as below: <table class="table ...
0 votes
4 answers
2k views
display newline on webpage [duplicate]
How can I make newlines become normal and display in the right way?