@app.template_filter(name='truncatechars')
def truncatechars(value, arg):
    try:
        length = int(arg)
    except ValueError: # Invalid literal for int().
        return value # Fail silently.
    if len(value) > length:
        return value[:length] + '...'
    return value
Truncates a string after a certain number of chars.
dataset/ETHPy150Open dcramer/sentry-old/sentry/web/templatetags.py/truncatechars