Skip to content

Commit 7667945

Browse files
committed
Added macro to SettingsPanel
1 parent 01b308e commit 7667945

2 files changed

Lines changed: 8 additions & 22 deletions

File tree

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% for settings in toolbar.settings.SETTINGS %}
1+
{% macro pprint_settings(settings, exclude=None) %}
22
{% if settings.__config__.title %}<h4>{{ settings.__config__.title }}</h4>{% endif %}
33

44
<table>
@@ -9,33 +9,18 @@
99
</tr>
1010
</thead>
1111
<tbody>
12-
{% for key, value in settings %}
12+
{% for key, value in settings.dict(exclude=exclude).items() %}
1313
<tr>
1414
<td>{{ key|escape }}</td>
1515
<td><code>{{ value|pprint|escape }}</code></td>
1616
</tr>
1717
{% endfor %}
1818
</tbody>
1919
</table>
20-
{% endfor %}
20+
{% endmacro %}
2121

22-
<h4>{{ toolbar.settings.__config__.title }}</h4>
22+
{% for settings in toolbar.settings.SETTINGS %}
23+
{{ pprint_settings(settings) }}
24+
{% endfor %}
2325

24-
<table>
25-
<thead>
26-
<tr>
27-
<th>Key</th>
28-
<th>Value</th>
29-
</tr>
30-
</thead>
31-
<tbody>
32-
{% for key, value in toolbar.settings %}
33-
{% if key != 'SETTINGS' %}
34-
<tr>
35-
<td>{{ key|escape }}</td>
36-
<td><code>{{ value|pprint|escape }}</code></td>
37-
</tr>
38-
{% endif %}
39-
{% endfor %}
40-
</tbody>
41-
</table>
26+
{{ pprint_settings(toolbar.settings, exclude=to_set(['SETTINGS'])) }}

debug_toolbar/toolbar.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ def render(self, template: str, **context: t.Any) -> str:
124124
toolbar=self,
125125
url_for=self.request.url_for,
126126
get_name_from_obj=get_name_from_obj,
127+
to_set=set,
127128
**context,
128129
)
129130

0 commit comments

Comments
 (0)