copier-org / copier

Library and command-line utility for rendering projects templates.
https://readthedocs.org/projects/copier/
MIT License
2.06k stars 182 forks source link

Add jinja2-strcase Jinja extension #1355

Open marcelmindemann opened 1 year ago

marcelmindemann commented 1 year ago

Actual Situation

Hi, copier already vendors https://gitlab.com/dreamer-labs/libraries/jinja2-ansible-filters/ to provide additional helpers and filters in templates. I would like to suggest adding https://pypi.org/project/jinja2-strcase/ as well, as bootstrapping a new project often involves rendering the project name in multiple cases in different contexts. For example, many micro services today include both business code and infrastructure-as-code in the same project. A Python project would require snake_case for the project name, whereas the CDK for AWS infrastructure would idiomatically use CamelCase. Makefile targets would idiomatically need kebab-case. Instead of manually crafting these different representations of the project name, jinja2-strcase would bring this to copier out of the box.

Desired Situation

-

Proposed solution

-

yajo commented 1 year ago

Indeed it looks like a nice filter for Copier use case. However, the need for ansible-filters is because of the to_nice_yaml, which is only available there and is very needed for copier answers files, which are a core Copier feature.

We can add it to the list of recommendations, as it really will be useful in many contexts, as you explained.

Does that seem good to you?