<s> from __future__ import absolute_import , unicode_literals <EOL> from django import template <EOL> from django . utils . safestring import mark_safe <EOL> from wagtail . wagtailcore import __version__ <EOL> from wagtail . wagtailcore . models import Page <EOL> from wagtail . wagtailcore . rich_text import RichText , expand_db_html <EOL> register = template . Library ( ) <EOL> @ register . simple_tag ( takes_context = True ) <EOL> def pageurl ( context , page ) : <EOL> """<STR_LIT>""" <EOL> return page . relative_url ( context [ '<STR_LIT>' ] . site ) <EOL> @ register . simple_tag ( takes_context = True ) <EOL> def slugurl ( context , slug ) : <EOL> """<STR_LIT>""" <EOL> page = Page . objects . filter ( slug = slug ) . first ( ) <EOL> if page : <EOL> return page . relative_url ( context [ '<STR_LIT>' ] . site ) <EOL> else : <EOL> return None <EOL> @ register . simple_tag <EOL> def wagtail_version ( ) : <EOL> return __version__ <EOL> @ register . filter <EOL> def richtext ( value ) : <EOL> if isinstance ( value , RichText ) : <EOL> return value <EOL> elif value is None : <EOL> html = '<STR_LIT>' <EOL> else : <EOL> html = expand_db_html ( value ) <EOL> return mark_safe ( '<STR_LIT>' + html + '<STR_LIT>' ) </s>
