Skip to content
Myr

Mention that people subscribe with **extra.

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parent 230e136 · Browse files · 1 file+4 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+4 added−1 removed

  • other:+4 added−1 removed

1 file+4 added−1 removed

modified:docs/signals.rst+4 added-1 removed
53 unmodified lines
5455 @contextmanager56 def captured_templates(app):57 recorded = []58 def record(sender, template, context):58 def record(sender, template, context, **extra):59 recorded.append((template, context))60 template_rendered.connect(record, app)61 try:62 yield recorded
9 unmodified lines
72 template, context = templates[0]73 assert template.name == 'index.html'74 assert len(context['items']) == 107576Make sure to subscribe with an extra ``**extra`` argument so that your77calls don't fail if Flask introduces new arguments to the signals.7879All the template rendering in the code issued by the application `app`80in the body of the `with` block will now be recorded in the `templates`81variable. Whenever a template is rendered, the template object as well as82context are appended to it.
176 unmodified lines