Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Wagtail template filter to resolve html
When editing the content use the brackets:
[[ <iframe>..</iframe> ]]
And after, use it in templates like this:
{{ page.body|resolve_html|richtext }}
# templatetags/
from django import template
register = template.Library()
def resolve_html(value):
new = value.replace('<p>[[', '')
new = new.replace(']]</p>', '')
new = new.replace('&lt;', '<')
new = new.replace('&gt;', '>')
return new
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment