Using and Mastering Cookiecutter Transcripts
Chapter: Creating Cookiecutter templates
Lecture: Concept: Extensions

Login or purchase this course to watch this video and the rest of the course contents.
0:01 Jinja2 comes with the ability to write extensions for its template language, here is the officially listed extensions as well as the API
0:09 that we can go to and write our own. We could also go to GitHub and do searches for those extensions,
0:14 and we saw that there were 25 of those, at the time of the recording, that is pretty cool, so if we want to use the extension,
0:21 we have to list it, right here in this _extensions. Now, unfortunately, this must be an installed Python package,
0:29 which means pip install package-name typically depending on, there is a few intricacies around which version of pip you're using
0:39 based on your path and so on, so this can get actually a little bit tricky for your users and it's too bad that it doesn't somehow install
0:46 this kind of automatically, as part of the template creation, so maybe there is some work to do, on this project to say look,
0:53 it requires these extensions if you either run this, this command or I can do it for you, as part of the execution,
1:00 and we'll set this up in your user profile, so from now on you can use these extensions there is a little bit of a security tightrope
1:07 to walk there but I think something like that would be really nice, it doesn't exist now so if you're going to do this,
1:12 your users have to install jinja2-time before they could run this template. But once we put this in here as an extension, then in our project,
1:19 we can say things like release date is {% now 'local' %} And that comes from the time extension, so that's really cool.


Talk Python's Mastodon Michael Kennedy's Mastodon