1 # -*- coding: utf-8 -*-
2 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
3 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
5 from django import template
6 from django.utils.encoding import force_unicode
7 from django.utils.safestring import mark_safe
9 from ajaxable.utils import placeholdized
10 register = template.Library()
14 def placeholdize(form):
15 return placeholdized(form)
19 def placeholdized_ul(form):
20 return placeholdized(form).as_ul()
24 def pretty_field(field, template=None):
28 <span class="error">%(errors)s</span>
29 <label class="nohide"><span class="label">%(label)s: </span>%(input)s</label>
30 <span class="helptext">%(helptext)s</span>
32 return mark_safe(template % {
33 'errors': field.errors,
35 'label': ('*' if field.field.required else '') + force_unicode(field.label),
36 'helptext': force_unicode(field.help_text),
41 def pretty_checkbox(field):
42 return pretty_field(field, template=u'''
44 <span class="error">%(errors)s</span>
45 <label class="nohide">%(input)s<span class="label"> %(label)s</span></label>
46 <span class="helptext">%(helptext)s</span>