copier icon indicating copy to clipboard operation
copier copied to clipboard

Add jinja2-strcase Jinja extension

Open marcelmindemann opened this issue 2 years ago • 1 comments
trafficstars

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

marcelmindemann avatar Oct 04 '23 12:10 marcelmindemann

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?

yajo avatar Oct 04 '23 17:10 yajo