Are expressions supported in cookiecutter.json?

18 Views Asked by At

I'm trying to do this in my cookiecutter.json:

{
    "herp": ["aaa", "bbb"],
    "derp": "{{ if cookiecutter.herp == 'aaa': return 'some_other_value'}}"
}

But I get this error: jinja2.exceptions.TemplateSyntaxError: expected token 'end of print statement', got 'cookiecutter'

I can do stuff like this though: "my_id": "{{ cookiecutter.my_name.lower().replace(' ', '-') }}"

Is there a way to do more advanced expressions between {{}}?

Edit

I still want to know if conditionals are supported, but I found you can do dict lookups! So this works for me:

"_my_dict": {"aaa":"sdfsdf", "bbb":"werwerwe"},
"derp": "{{cookiecutter._my_dict[cookiecutter.herp]}}",
0

There are 0 best solutions below