def _mako_template_names(template):
    """
    Return all the used identifiers in the Mako template.

    From Igonato's code at https://stackoverflow.com/a/23577289/622408.
    """
    from mako import lexer, codegen
    lexer = lexer.Lexer(template)
    node = lexer.parse()
    compiler = lambda : None
    compiler.reserved_names = set()
    identifiers = codegen._Identifiers(compiler, node)
    return identifiers.undeclared
