Cookiecutter templates are no good

Cookiecutter templates are no good

In theory, Cookiecutter templates sound like a great idea. Just create a bunch of Jinja2 templates, give them context, and voila.

Tools like Copier and Yeoman are also similar.

If you look on my Github, you see some Cookiecutter templates and I’ve been using this tool since 2016.

But what happens when you want to test your product? What about when you want to update your template with more features?

Updating sucks

The template is simply a bunch of Jinja2 files. So if you want to test new features, you have to work on a separate instance of the template and then copy your features over manually.

Testing this is also tedious, especially if your template has dependencies on services like database.

What to do instead

Now that I think about it, all we’re doing is replace a bunch of strings in a few files. It’s not like we need everything to be templates.

What better way to replace string than by using sed?

That what I did on my Django project template . Development on my template was lagging behind because it’s always a chore to update Cookiecutter based templates.

For example, I wanted to update it to use my new way of configuring projects using configparser and running tests with pytest. Now that the project is just a regular project instead of a template, I can hack on it whenever I want.