Intro to Jinja Templates

Full Transcript

it's

in a previous videos we saw how impractical it easy to do mine you'll see handling to create HTML talking

it is good here we're going to focus on OB really powerful feature from floss which he's the usage of complete engine

we're going to use template anxious to Sherri HTML documents you know news your way

so the first thing we're going to do is of course I am comment

are both three

mon you'll owe three complaints training side view I'm going to take a look at these particulate public

I will see that I have a simple piece of HTML document because I used to have a but in this case I see these kind of strange place holder

this our place holders that are going to be used by the floss template and

the template engine use five classic is Cole she chats whom and even though it seems like it's their only template image that we can use it's actually something that we can

change we can provide a special settings to change the template engine that we're going to

well of course of by default we are going to use they she chats with template and

the purpose of a damnation is to provide a better language to specify or create talk

of course we will be focusing on creating HTML documents by you could easily create Shea some documents seniors are commands at

in this case what we're doing is just finding a place holder in this case librarian names so we have from some folks from some data source we have gotten date name all core library

and what we wanted to he's injecting even our HTML documents you know you know callable wait if you want without doing string manipulation in this guy's what we're doing is we're defining the HTML document

creating the place holder on what we want to render a dis HTML what they're telling you should

the surrender template strength function that we import from the flask more deal to combine the

HTML document the one with placeholders with the data that we want to use to fill these placeholders

so it is can we how welcome to our library name that's displayed hope placeholder and then we will combine then in

flying right here I'm in will basically put the content of their viable library name you

side that plays older than a house

we

I'm going to quickly change the names so you see that financed us how to be always related we're schists referencing of the

parliamentary use teen vogue to function with a placeholder we have created so I'm going to do something like

humble remove these

remove these

and you will see that people work I'm going to show you how it's working right now

so we have basically the po name that was specified in a different

viable on a list combine

in this line right here by they run their template stream function where combining the HTML would it place holder with the data that we one o'clock inside out

in this case I have a great included decoder to construct their HTML list with our offer

in this case we are including the authors we having the author's viable that we do think that it was retrieved for example from a battery

that way we disease is by using a horror loop which is a feature from the show in Japan

so let me show you first how it works if I reload the page I will see their list of authors Chanderi I will try for example removing one of these authors

and you will see how it was generated again dynamic

they boredom part is of course vis one right here in which we are doing a for loop how we're basically eatery thing through that offers particle these one right here

this author is horrible was fed it to the run their template three as we were doing with the library

so we're basically combining the HTML document of HTML initial viable there one with the place holders with the data that we want to use to fill those blank spots in this case the authors viable points basically today offers least and then we are inside a template word eatery king through all these authors on we are creating on you list item for everyone off the house first we have if we expect this source code shin radio we see basically what we were doing before

this is a simple example how to use HTML and pamphlet Asians but we still are having an issue we have a big

HTML code is her pike them

we're combining by sending HTML and that's is of course something that we want it fixed I will do it in the next

mmhm