import jinja2


def make_jinja_env(templates_dir):
    """
    Create the default Jinja environment given the template folder.

    Parameters
    ----------
    templates_dir : str or pathlib.Path
        The path to the templates.

    Returns
    -------
    env : jinja2.Environment
        The environment used to render the templates.
    """
    # Need to add the current dir so we can use the Markdown files as templates
    env = jinja2.Environment(
        loader=jinja2.FileSystemLoader([str(templates_dir), "."], followlinks=True),
        extensions=["jinja2.ext.do", "jinja2.ext.loopcontrols"],
    )
    return env