import re


def job_name_matches_template(job_name, template):
    """Checks if the job name matches the job template string.

    For example, a job named 'gate-stackviz-npm-run-test' will match a template
    string 'gate-{name}-npm-run-{command}'.

    :param job_name: the job name to check
    :param template: the job name template to compare against
    :return: True if the name matches the template string, otherwise False
    """
    # convert template to a regex
    regex = re.sub(r'\{[\w\-]+\}', r'[\w\-]*', template)

    return re.match(regex, job_name) is not None