Using and Mastering Cookiecutter Transcripts
Chapter: Creating Cookiecutter templates
Lecture: Concept: Bare template

Login or purchase this course to watch this video and the rest of the course contents.
0:01 We saw that the project folder structure is one of the core things
0:04 we have to work with, when creating these templates.
0:07 So here we're going to create a project, a Cookicutter template
0:11 and we're calling it your project name,
0:14 probably it should be cookiecutter-your-project-name,
0:16 or something to that effect, the top level directory called
0:19 your project name here, this is actually the name of the Cookicutter template,
0:23 not the thing it generates,
0:26 and we also have a notes.txt, a,,
0:29 these are just files that come along with the template
0:33 that will not ever make their way to the user,
0:36 but whoever comes to the template they can read those they can use those,
0:39 there could even be a little scripts that do things for you.
0:42 We saw there is basically two things for this to be a Cookiecutter template,
0:45 one we have to have our JSON file here, our cookiecutter.json,
0:50 this tells Cookiecutter two things,
0:53 what are the replaceable values that we can use,
0:56 and what default values do they have, the other thing is what are the prompts,
1:00 basically they are the same thing, what questions do we ask the user.
1:04 Okay, so that is that one, we also need a project,
1:07 so here we're going to have a {{cookiecutter.project_name}} thing,
1:12 this is all Jinja type expressions, and then,
1:15 whatever we want to copy and modify for the users,
1:19 we're going to put that where ... goes,
1:22 as a subdirectory, or subfiles under this directory here.
1:25 Now, this is a simplified version of the template,
1:28 there is actually other things like pre and post generation hooks and whatnot,
1:31 but remember, we're starting from a bare directory,
1:34 a bare project and we're going to get more advanced
1:36 and bring these things in as they make sense. If we want to run this,
1:39 we are going to come here and we're going to enter the cookiecutter
1:43 and then we'll say the name or location of the template,
1:45 if we've already installed it off of GitHub or somewhere like that
1:48 we can say the short name, in this case pyramid-cookiecutter-starter
1:51 already given the full GitHub name and it's cloned into .cookiecutters,
1:55 but if we don't, of course we have to say the full name, or if it's local,
1:58 we have to say the actual file path to it, and in there,
2:01 there is a cookiecutter.json with a bunch of questions,
2:03 project name, repo name,
2:05 notice here we have an interesting pick number 1 or number 2 out of this list.
2:09 That is called a choice value and we'll get the choice values later,
2:12 so where do these questions come from?
2:15 They come from cookiecutter.json, right, we've already seen this,
2:18 the keys here in this JSON object are the questions or the replaceable values
2:23 and the values in the cookiecutter.json those are the default values.
2:26 So that's it, you can see it is really really simple
2:30 to create these Cookiecutter templates
2:33 and with all the benefits available to you that I laid out at the beginning,
2:36 why not, right, this is so easy to add so much reproducibility and reliability
2:40 to almost any type of software project
2:43 or just file structured thing that you're doing.