Open OverkillGuy opened 1 year ago
This ticket and a few others I opened (and will open) are things I always wished cookiecutter could do, but the "advanced maturity" of the project was holding back massive changes of the sort.
Now that I see new blood injected in the project, I'm opening up the complaints department to write a bunch of feature requests! Hoping that's valuable to all, not just nagging =D
copier can do it
Long-requested feature of cookiecutter: conditional file inclusion.
I wish to make a template that can generate a Kubernetes Helm chart, or don't, based on how comfortable people are with Kubernetes (or just fall-back to docker-compose file). To do this currently, I need to add a post-gen hook script that runs
rm -r kubernetes_subfolder
after generation, or something more elaborate[1].I wish files or folders could be not included based on an
if
expression in filename: filenamecli.py {% if cookiecutter.is_cli %}
or{% if cookiecutter.kubernetes_scaffold%} k8s
. Not fussy with the syntax, just wish it was in filename, not requiring a file deletion system.[1]: My overcomplicated but "so elegant" solution, used here is to have all conditional files have sentinel content if they shouldn't be included see example, and in post-gen hook, fingerprint (sha256) the sentinel string, fingerprint all the expanded files, then delete the files with sentinel-string-hash.