I would like to use dynamic variables inside hooks/pre_gen_project.py.
When I add a static text inside the hook file it works:
{{ cookiecutter.update({"venv_path": "static/venvpath", "py_path": "static/pypath"}) }}
But when I tried to use a variable like venv_path_val
venv_path_val = "static/venvpath"
py_path_val = "static/pypath"
{{ cookiecutter.update({"venv_path": venv_path_val, "py_path": py_path_val }) }}
I am getting
jinja2.exceptions.UndefinedError: 'venv_path_val' is undefined
I also tried it inside eval
but no luck:
eval("{{ '{{'|safe }} cookiecutter.update({'venv_path': venv_path, 'py_path': py_path}) {{ '}}'|safe }}")
So is there a way to inject my dynamic template variables inside cookiecutter?