def lookup(parser, var, context, resolve=True, apply_filters=True):
if resolve:<EOL><INDENT>try:<EOL><INDENT>return Variable(var).resolve(context)<EOL><DEDENT>except VariableDoesNotExist:<EOL><INDENT>if apply_filters and var.find('<STR_LIT:|>') > -<NUM_LIT:1>:<EOL><INDENT>return parser.compile_filter(var).resolve(context)<EOL><DEDENT>return Constant(var)<EOL><DEDENT>except TypeError:<EOL><INDENT>return var<EOL><DEDENT><DEDENT>return var<EOL>
Try to resolve the varialbe in a context
If ``resolve`` is ``False``, only string variables are returned