Support of ./extensions/ directory in template#1340
Support of ./extensions/ directory in template#1340con-f-use wants to merge 9 commits intocookiecutter:masterfrom con-f-use:master
./extensions/ directory in template#1340Conversation
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/. |
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. |
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_extensionskeyword to import extensions for a new./extensionsdirectory 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.