New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow Jinja extensions to be defined/bundled in the template repository #944
Conversation
Codecov Report
@@ Coverage Diff @@
## master #944 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 17 17
Lines 684 686 +2
=====================================
+ Hits 684 686 +2
Continue to review full report at Codecov.
|
@hackebrot any feedback? |
@ramnes Looks good. Have you got any real cases when you've used Jinja Extensions? |
Yeah, at numberly we use our fork and we leverage this feature a lot. We use filters almost everywhere, because it's so convenient to output different things based on a single input. The example in my first comment is very basic but shows pretty well how we're using it. |
Could you PM the rest of the Team on Gitter about your progress? 👍 |
@theodesp I've already done that in July, without much success. 😞 |
I would support a more explicit solution to this issue:
|
This implementation is how I expected cookiecutter to work in the first place, and it's good to have instinctive behaviors working out of the box. I'd be open to implement it the way you say, but it would take more time, wouldn't be as obvious since you'd have to look at the docs, whereas here it's super simple and just works… Don't want to keep it simple? What are the downsides? |
I hacked together something to make this available without a fork.
Only requires you to have Not pretty and I'm not great at python so forgive the quality. Just a work-around for people who need want this feature but don't want to maintain a fork. The code here is if you're interested: https://gist.github.com/ilsken/79f3077a72a9113f3e83ae44c8289f77 |
@pydanny gentle ping As said on gitter two months ago, done is better than perfect, and this is a two lines diff that's sitting here for more than a year now. Can we do something about it? |
Note to myself: just implement that |
Codecov Report
@@ Coverage Diff @@
## master #944 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 18 18
Lines 783 785 +2
=====================================
+ Hits 783 785 +2
Continue to review full report at Codecov.
|
Great! |
This commit permits users to define custom Jinja extensions to be used in the
cookiecutter.json
file.For example, with something like this in
template/helpers.py
:It allows to use that Jinja filter directly:
This is really just a dumb example, but I'm pretty confident that it could be a powerful feature.
I'm kinda new to Cookiecutter, so please point me to the right direction if there's already another way to achieve something like this that I'm not aware of.