(
app: Flask, template: Template, context: dict[str, t.Any]
)
| 164 | |
| 165 | |
| 166 | def _stream( |
| 167 | app: Flask, template: Template, context: dict[str, t.Any] |
| 168 | ) -> t.Iterator[str]: |
| 169 | app.update_template_context(context) |
| 170 | before_render_template.send( |
| 171 | app, _async_wrapper=app.ensure_sync, template=template, context=context |
| 172 | ) |
| 173 | |
| 174 | def generate() -> t.Iterator[str]: |
| 175 | yield from template.generate(context) |
| 176 | template_rendered.send( |
| 177 | app, _async_wrapper=app.ensure_sync, template=template, context=context |
| 178 | ) |
| 179 | |
| 180 | rv = generate() |
| 181 | |
| 182 | # If a request context is active, keep it while generating. |
| 183 | if request: |
| 184 | rv = stream_with_context(rv) |
| 185 | |
| 186 | return rv |
| 187 | |
| 188 | |
| 189 | def stream_template( |
no test coverage detected
searching dependent graphs…