X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/ae60b2a3949e96357477cc04f90fd0873cee8a92..652e2d66d7f88cc6b857edc4aaac7e14a654eb36:/src/ajaxable/templatetags/ajaxable_tags.py diff --git a/src/ajaxable/templatetags/ajaxable_tags.py b/src/ajaxable/templatetags/ajaxable_tags.py index 351e9f13d..c262a92c3 100644 --- a/src/ajaxable/templatetags/ajaxable_tags.py +++ b/src/ajaxable/templatetags/ajaxable_tags.py @@ -3,6 +3,8 @@ # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # from django import template +from django.utils.safestring import mark_safe + from ajaxable.utils import placeholdized register = template.Library() @@ -15,3 +17,23 @@ def placeholdize(form): @register.filter def placeholdized_ul(form): return placeholdized(form).as_ul() + + +@register.filter +def pretty_field(field, template=None): + if template is None: + template = ''' +
  • + %(errors)s + +
  • ''' + return mark_safe(template % {'errors': field.errors, 'input': field, 'label': field.label}) + + +@register.filter +def pretty_checkbox(field): + return pretty_field(field, template=''' +
  • + %(errors)s + +
  • ''')