File tree 2 files changed +6
-10
lines changed
templates/debug_toolbar/panels 2 files changed +6
-10
lines changed Original file line number Diff line number Diff line change 3
3
from django .template import Origin , TemplateDoesNotExist
4
4
from django .template .engine import Engine
5
5
from django .template .loader import render_to_string
6
- from django .utils .safestring import mark_safe
6
+ from django .utils .html import format_html , mark_safe
7
7
8
8
from debug_toolbar .decorators import require_show_toolbar
9
9
@@ -50,12 +50,12 @@ def template_source(request):
50
50
from pygments import highlight
51
51
from pygments .formatters import HtmlFormatter
52
52
from pygments .lexers import HtmlDjangoLexer
53
-
53
+ except ModuleNotFoundError :
54
+ source = format_html ("<code>{}</code>" , source )
55
+ pass
56
+ else :
54
57
source = highlight (source , HtmlDjangoLexer (), HtmlFormatter ())
55
58
source = mark_safe (source )
56
- source .pygmentized = True
57
- except ImportError :
58
- pass
59
59
60
60
content = render_to_string (
61
61
"debug_toolbar/panels/template_source.html" ,
Original file line number Diff line number Diff line change @@ -5,10 +5,6 @@ <h3>{% trans "Template source:" %} <code>{{ template_name }}</code></h3>
5
5
</ div >
6
6
< div class ="djDebugPanelContent ">
7
7
< div class ="djdt-scroll ">
8
- {% if not source.pygmentized %}
9
- < code > {{ source }}</ code >
10
- {% else %}
11
- {{ source }}
12
- {% endif %}
8
+ {{ source }}
13
9
</ div >
14
10
</ div >
You can’t perform that action at this time.
0 commit comments