Skip to content

Commit eeb624d

Browse files
committed
fix rendering
1 parent 81c7f43 commit eeb624d

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

djangocms_rest/apps.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from django.apps import AppConfig
2+
3+
4+
class DjangocmsRestConfig(AppConfig):
5+
"""
6+
AppConfig for the djangocms_rest application.
7+
This application provides RESTful APIs for Django CMS.
8+
"""
9+
default_auto_field = "django.db.models.BigAutoField"
10+
name = "djangocms_rest"
11+
verbose_name = "Django CMS REST API"
12+
13+
def ready(self):
14+
try:
15+
from djangocms_text import settings
16+
17+
settings.TEXT_INLINE_EDITING = False
18+
except (ImportError, ModuleNotFoundError):
19+
pass

djangocms_rest/plugin_rendering.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@ def highlight_data(json_data: Any) -> str:
115115
if json_data is None:
116116
return '<span class="null">null</span>'
117117
if isinstance(json_data, dict):
118-
return OBJ_TEMPLATE.format(**highlight_json(json_data)) if json_data else '{}'
118+
return highlight_json(json_data).get("value", "") if json_data else '{}'
119119
if isinstance(json_data, list):
120-
return OBJ_TEMPLATE.format(**highlight_list(json_data)) if json_data else '[]'
120+
return highlight_list(json_data).get("value", "") if json_data else '[]'
121121

122122
return f'<span class="obj">{json_data}</span>'
123123

@@ -133,8 +133,8 @@ def highlight_json(
133133
DETAILS_TEMPLATE.format(
134134
key=escape(key),
135135
value=highlight_data(value),
136-
open='',
137-
close='',
136+
open='{' if isinstance(value, dict) else '[',
137+
close='}' if isinstance(value, dict) else ']',
138138
) if isinstance(value, (dict, list)) and value else SIMPLE_TEMPLATE.format(
139139
key=escape(key),
140140
value=highlight_data(value),

0 commit comments

Comments
 (0)