Use Jinja2 rendering for given text an key key/values.

    Args:
        value (str): the template to be rendered.
        kwargs (dict): named parameters representing available variables
                       inside the template.

    >>> model = {"message": "hello world 1!"}
    >>> rendered_text = render("{{model.message}}", model=model)
    >>> rendered_text == 'hello world 1!'
    True
    >>> model = {"message": "hello world 2!", "template": "{{ model.message }}"}
    >>> rendered_text = render("{{ model.template|render(model=model) }}", model=model)
    >>> rendered_text == 'hello world 2!'
    True

    The pipeline process is all about Bash code (inside and outside Docker) and
    autoescaping wouldn't help. Usually the pipeline runs in a isolated environment
    and there should not be any injection from outside; that's why: nosec.

def render(value, **kwargs):
    """
    Use Jinja2 rendering for given text an key key/values.

    Args:
        value (str): the template to be rendered.
        kwargs (dict): named parameters representing available variables
                       inside the template.

    >>> model = {"message": "hello world 1!"}
    >>> rendered_text = render("{{model.message}}", model=model)
    >>> rendered_text == 'hello world 1!'
    True
    >>> model = {"message": "hello world 2!", "template": "{{ model.message }}"}
    >>> rendered_text = render("{{ model.template|render(model=model) }}", model=model)
    >>> rendered_text == 'hello world 2!'
    True

    The pipeline process is all about Bash code (inside and outside Docker) and
    autoescaping wouldn't help. Usually the pipeline runs in a isolated environment
    and there should not be any injection from outside; that's why: nosec.
    """
    try:
        environment = Environment(autoescape=False)  # nosec
        environment.filters['render'] = render
        environment.filters['docker_environment'] = docker_environment
        environment.filters['find_matrix'] = find_matrix
        environment.filters['find_stages'] = find_stages
        template = environment.from_string(value)
        return template.render(**kwargs)
    except UndefinedError as exception:
        Logger.get_logger(__name__).error("render(undefined): %s", exception)
    except TemplateSyntaxError as exception:
        Logger.get_logger(__name__).error("render(syntax error): %s", exception)
    return None