Compare commits

...

2 Commits

Author SHA1 Message Date
app 713f9ca9e3 Working version of adding html_content 2023-05-16 10:30:01 +00:00
app 0289586811 Add custom_filters : ph_html_decode 2023-05-16 10:28:45 +00:00
4 changed files with 15 additions and 4 deletions

View File

@ -0,0 +1,8 @@
from django import template
from html import unescape
register = template.Library()
@register.filter
def ph_html_decode(value):
return unescape(value)

View File

@ -257,8 +257,6 @@ class ArticlePage(Page):
ImageChooserPanel('feed_image'),
], heading="Images"),
StreamFieldPanel('gallery'),
]
content_panels = Page.content_panels + [
FieldPanel('html_content', classname='full'),
]
promote_panels = [

View File

@ -1,4 +1,4 @@
{% load wagtailcore_tags wagtailimages_tags %}
{% load wagtailcore_tags wagtailimages_tags custom_filters %}
{% if page.feed_image %}
<div class="image">
@ -34,7 +34,9 @@
{% if page.html_content %}
<!-- Any other content -->
<div class="article-body">
{{ page.html_content|richtext }}
{% autoescape off %}
{{ page.html_content|ph_html_decode }}
{% endautoescape %}
</div>
{% endif %}

View File

@ -109,6 +109,9 @@ TEMPLATES = [
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
'libraries': {
'custom_filters': 'publichealth.home.custom_filters',
},
},
},
]