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
Support of ./extensions/
directory in template
#1340
Conversation
Debatabely, this should rather be a warning and return an empty `config_dict`
As mentioned, this is similar to #1240 and #944 . @ssbarnea @insspb If anything, make the folder name in #1240 just extensions instead of local_extensions to go along with ./hooks/. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests!
Co-Authored-By: Andrey Shpak <insspb@users.noreply.github.com>
as per sugeesten
@con-f-use As I mention earlier some tests required. This feature can be useful for some part of users, who want to deliver own extensions without pip packages. But it is not just path extension. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please look at comment above.
I wouldn't worry about these two cases. The python import system will catch the first one. For the last, IMHO it is not necessary to check if it is an extension. If Jinja cannot find the extension, it will complain and I'd leave it to Jinja. Besides we have no way of knowing, whether the user wants to include a pip installed extension with I'd not explicitly forbid that something other than Jinja extension - it's actually a nice feature if it can be a normal python package or module in there and the directory is not permanently added to the path. Also, we already have arbitrary code execution by virtue of having hooks. Elaborate verification would just over-complicate things with no benefit. That being said, I will write a test, that verifies an actual Jinja2 extension can be imported and used. Just not today ;-) |
@con-f-use I just found #1240 and seems it is more correct implementation of same thing and almost done. |
In
cookiecutter.json
, you can now use the_extensions
keyword to import extensions for a new./extensions
directory in the template (similar to./hooks/
).For some related discussion see e.g.: #1211 and #547
The updated documentation has a more detailed description.
I would be willing to write additional tests to test this functionality.
Also. the "new in version ???" from my documentation should be updated before merging and releasing, same as release notes obviously.