1 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
2 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
4 from django import template
5 from django.utils.encoding import force_str
6 from django.utils.safestring import mark_safe
7 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_str(field.label),
36 'helptext': force_str(field.help_text),
41 def pretty_checkbox(field):
42 return pretty_field(field, template='''
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>