Created
September 27, 2016 18:57
-
-
Save PabloLefort/00be2b09a26791a467fa2aec83a6e195 to your computer and use it in GitHub Desktop.
Wagtail template filter to resolve html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
When editing the content use the brackets: | |
[[ <iframe>..</iframe> ]] | |
And after, use it in templates like this: | |
{{ page.body|resolve_html|richtext }} | |
""" | |
# templatetags/mytags.py | |
from django import template | |
register = template.Library() | |
@register.filter | |
def resolve_html(value): | |
new = value.replace('<p>[[', '') | |
new = new.replace(']]</p>', '') | |
new = new.replace('<', '<') | |
new = new.replace('>', '>') | |
return new |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment