Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Flask Render Text from Variable like render_template

I know the flask function render_template. I have to give the file name of the template. But now I want to render the string of a template (that is the content of the template). That makes sense. but I don't want to explain now why. How can I render the text of a template simply?

like image 223
Faminator Avatar asked Oct 28 '15 21:10

Faminator


1 Answers

You can use render_template_string:

>>> from flask import render_template_string >>> render_template_string('hello {{ what }}', what='world') 'hello world' 
like image 100
ThiefMaster Avatar answered Sep 17 '22 19:09

ThiefMaster