import json

from django import template

register = template.Library()


@register.filter
def pprint(value):
    if isinstance(value, (dict, list)):
        return json.dumps(value, indent=2)
    return value
