def METHOD_NAME(match: Match) -> str:
    var_name = match.group(1)
    try:
        return template_kwargs[var_name]
    except KeyError:
        raise BadTemplateError(
            "Bad template, referenced template var that does not "
            "exist: '%s', for template contents:\n%s"
            % (var_name, contents)
        )