Hello All, I'm try to get away from doing if/else in a template:
{% if x.message|regtest == "True" %} do something cool {% else %} do something less cool {% endif %} given this template filter: @register.filter(name='regtest') def regtest(value): regex = re.compile(r'^\*\*(?P<message>.*)\*\*') m = regex.match(value) if m != None: return "True" return "False" I would like to move to something like this in the template: {{ x.message|regtest }} given this template filter: def regtest(value): regex = re.compile(r'^\*\*(?P<message>.*)\*\*') m = regex.match(value) if m != None: return "<b><i>%s</i></b>"%value else: return value However, the html tags returned from the filter becomes part of the element's text value instead of tags. So that's not working. I'm sure there's way better ways to side-step ugly if/else logic in the templates. What types of things can people recommend for a Django new guy. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.