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?
You can use render_template_string
:
>>> from flask import render_template_string >>> render_template_string('hello {{ what }}', what='world') 'hello world'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With