Complete worked example
python
from flask import Flask, render_template_string
app = Flask(__name__)
app.config['TESTING'] = True
def render_title(title):
with app.app_context():
return render_template_string('<h1>{{ title }}</h1>', title=title)- Reasoning
- The helper renders a short heading through Flask’s render_template_string within an application context. A title containing angle brackets remains visible text after escaping.