11
11
from .models import SnippetPtr
12
12
13
13
14
- CACHE_ENABLED = getattr (settings , ' DJANGOCMS_SNIPPET_CACHE' , False )
14
+ CACHE_ENABLED = getattr (settings , " DJANGOCMS_SNIPPET_CACHE" , False )
15
15
16
16
17
17
class SnippetPlugin (CMSPluginBase ):
18
18
model = SnippetPtr
19
- name = _ (' Snippet' )
20
- render_template = ' djangocms_snippet/snippet.html'
19
+ name = _ (" Snippet" )
20
+ render_template = " djangocms_snippet/snippet.html"
21
21
text_enabled = True
22
22
text_editor_preview = False
23
23
cache = CACHE_ENABLED
@@ -26,25 +26,28 @@ def render(self, context, instance, placeholder):
26
26
try :
27
27
if instance .snippet .template :
28
28
context = context .flatten ()
29
+ context .update ({"html" : mark_safe (instance .snippet .html )})
29
30
t = template .loader .get_template (instance .snippet .template )
30
31
content = t .render (context )
31
32
else :
32
33
# only html provided
33
34
t = template .Template (instance .snippet .html )
34
35
content = t .render (context )
35
36
except template .TemplateDoesNotExist :
36
- content = _ (' Template %(template)s does not exist.' ) % {
37
- ' template' : instance .snippet .template
37
+ content = _ (" Template %(template)s does not exist." ) % {
38
+ " template" : instance .snippet .template
38
39
}
39
40
except Exception as e :
40
41
content = escape (str (e ))
41
42
42
- context .update ({
43
- 'placeholder' : placeholder ,
44
- 'object' : instance ,
45
- 'html' : mark_safe (instance .snippet .html ),
46
- 'content' : content ,
47
- })
43
+ context .update (
44
+ {
45
+ "placeholder" : placeholder ,
46
+ "object" : instance ,
47
+ "html" : mark_safe (instance .snippet .html ),
48
+ "content" : content ,
49
+ }
50
+ )
48
51
49
52
return context
50
53
0 commit comments