Adding a CMS to Your Flask Web App Transcripts
Chapter: Advanced markdown
Lecture: Using markdown-subtemplate in the viewmodel
0:00 it's time to start bringing markdown sub templates into our project. So, first, as usual,
0:07 using an external library from my P I we're going to put it into our requirements over here to say that we want to use it.
0:14 So we're gonna use markdown sub template and nobody arm. It's not misspelled. So we could either installed Nashar requirements dot txt or,
0:22 you know, just click this button and let high time take care of it. Okay, now that that's installed,
0:28 that's looking good Over here. We were converting to mark down, using our own code that we had written right.
0:36 We wrote this function were using marked down to with the options. All that was buying, however, remember, it was slow. We can't reuse stuff,
0:45 all the limitations. So let's not do this. Let's comment that out. And the k we're not using it and same thing here
0:53 So instead of calling that what we're gonna do is we're gonna use the markdown
0:59 sub template. So let's go over here and say import marked down sub template like that. If you go to mark down sub template.
1:10 There's this thing called an engine and the engine we can get the page. It takes the template path. Well,
1:16 we can just use the Earl passed that subdural through. It also allows us to much like Jinja,
1:23 take variables and replace them in the markdown with values that were passing from code. That's that data you can see.
1:30 But right now it's just an empty dictionary. We're not really using that. Like we don't have any data to pass along in
1:36 this use case, so it doesn't make sense breast to pass any Data's Where is gonna leave that out. Soas faras using marked on sub template This is it.
1:45 We're done. However, we're not done setting it up. There's one more thing we got to do. So let's go and try to view something over here.
1:53 Let's try to go. What could help, for example, Boom. What happened? Well, illegal operation storage engine is not initialized.
2:03 Okay, What does that mean? Well, what it means is we have to explicitly tell either where the files are
2:11 if we're going to use markdown files off of disk like the default or we have to teach it how to talk to our database or something like Red is or even
2:22 a Web service. However, we're going to talk to how we're gonna store and retrieve are marked down right now. Reason. Sequel. Alchemy in the database.
2:28 We just haven't set that up yet, So it threw up his hands and said, Look, I could use the file system, but you haven't told me where the files are.
2:36 And by the way, if you want to do something else, I also can't, you know, anticipate that. So the next thing we got to do is set that up,
2:43 but it's really quite easy as you'll see.