def get_template_context(node, context, context_lines=3):
    source = getattr(node, 'source', None)
    # In Django 1.9 template Node does not have source property, Origin does
    # not reload method, so we extract contextual information from exception
    # info.
    if source:
        line, source_lines, name = get_template_source_from_source(source)
    else:
        line, source_lines, name = get_template_source_from_exception_info(
            node, context)
    debug_context = []
    start = max(1, line - context_lines)
    end = line + 1 + context_lines

    for line_num, content in source_lines:
        if start <= line_num <= end:
            debug_context.append({
                'num': line_num,
                'content': content,
                'highlight': (line_num == line),
            })

    return {
        'name': name,
        'context': debug_context,
    }
dataset/ETHPy150Open django-debug-toolbar/django-debug-toolbar/debug_toolbar/utils.py/get_template_context/original