Using and Mastering Cookiecutter Transcripts
Chapter: Creating Cookiecutter templates
Lecture: Demo: Dependent values
Login or
purchase this course
to watch this video and the rest of the course contents.
0:01
So we've seen that the prompts come from cookiecutter.json, and cookicutter.json as the json extension would indicate, seems very static,
0:11
like if it was cookiecutter.js well, maybe we put a whole bunch of conditionals and things like that, but just a json file,
0:20
that indicates static values, so let's run this Cokiecutter template cookiecutter-template, that's right, it's a meta cookiecutter-template,
0:28
this is the one that we can use actually to create other Cookiecutters, I just want to look at a question it asks, so let's run this,
0:34
and it says great, what's your name, my name is Michael, here is my email address, my username "this will be the funnest project template evah'",
0:50
So if we say this, watch what the next prompt is. Cookiecutter-the-funnest-project-evah, now I think that little dash
0:58
might be causing me trouble but let's go and give it a shot anyway. The important thing to notice is look it took this value,
1:04
that I entered here and it didn't just clone it, it actually did something interesting here, it turned it into what is called a slug,
1:11
or project slug, it basically lower cased it, there is probably a bug in it, should remove quotes and things like that, a punctuation,
1:18
and in here it put little dashes, right, so this is a good directory name besides that little quote that got on the end, so we can keep going with this
1:27
and we just pick the defaults here, notice another thing, look at that, that is actually today, right, that's the day that I am recording this.
1:35
This value changes if I run this tomorrow it will say 2017, 03 10. That's really cool, and the version oh no, this is a very advanced template,
1:44
it's there, do you want to copy the hooks- no, don't worry about the details here,
1:49
yeah, I don't think it can take this dash, but I suppose I did it right, it would also generate a thing that we could start,
1:57
so instead of one we did in a previous video with the bare template, we can start from this one, we'll come back to this,
2:02
the important thing here is that we entered the value here, and it worked there,
2:06
and we also have time that is live here so these are two separate concepts the first one we'e going to focus on is how did this happen,
2:15
so let's go over here and we'll say cd that, right, now if we look in here, we'll see a couple of things, let's just look at this cookiecuter.json,
2:26
so check this out, this is the one where I typed the the funnest project evah,
2:33
and down here, look what's in here, we have cookiecutter-and then we have, I'll go and just wrap it for you, obviously, that doesn't make any sense,
2:42
but we have cookiecutter-{{ that's a Jinja expression, and here that relates back to that, right, and then we'e doing additional processing,
2:51
lower replace cookiecutter strip replace spaces with this, I think we could do a little bit more work, we could add our dash or quotes,
3:01
or things like that, punctuation we can get that out of here, that would be no problem, we'll just add it on this,
3:08
so these values here they can actually be live Jinja expressions and the value available to them, basically all the values,
3:17
all the questions that have been asked or prompts that have been run previously are available,
3:22
in this case, particularly we're interested in project_name. The other thing that's cool is, down here released it we have % now.
3:31
Okay what is % now, we'll come back and figure out what that is in a little bit.