Templates to files

Full Transcript

it's

your previous videos we made progress from money only stream paneling to create HTML to deliver a shame on the powerful she should template and shame to create more callable underboss templates to provide better HTML talk

the only shortcoming is if we were Shahar coating the HTML template use are are lost view we will basically combining

I think code with HTML code

that python park in our flask application will usually deal with business talk it will not have to deal with presentation which

separate business logic from

from presentation so what we're going to do is move the template code to another place basically Willis torrent in an independent file that is going to be each year for us to get a local and also for any other designer and we have

and we will reference dot HTML choir from inside our

plus function that they go look

in this example we're going to use our course obligation that one contained on all four complete outside queue morning but when you first to compare it with the one in the previous example

in this case we have our our entire template contained in day python function

just as a big strain in this case what we're going to have peace we will take out all the scooter to a different file in these cases call index that HTML and we will schist reference fees

template file from our pipes and function there a few things to understand here

the first thing is that there template function we were calling now how

change we are not using anymore there one name brand their template strain but where you seen one that is called just bring their family

we are damned referencing friend their templates I'm we're passing the name of the template that we

surrender

this name by the full is a file that will leave inside that template directory disease by default something from class

we can of course change that but we've we like these conventions we photo ID so inside templates directory you have I mean they accept HTML file that basically contains they could they HTML document that we want to use I SO placeholder for our documents

so in this case the only difference is to showcase that they are actually different is that we are just changing the call or or quiet or entire document to read

so I'm just going to reload his page

and you will see how these all read it as its base of fire right here

so again this super simple wishes to move there HTML code into a different file we have chosen a good name for it I'm inside our python function whenever we want to invoke dot

HTML document or template where she just referencing it by name they boredom are here again ease by its too used to correct name for directory in this case if the panel place directory

if you follow their example inner give how repository it will be a rented out for you

I can just take a look at how it works

finally all the features that we have

talk about up to this point are from the she shut pamphlet and shin they are not actually from flask

flossing ease you seem mission shop played engine if you ever have an issue it will likely be a related to change how I'm not a plus for that's a good idea to check in the communication off their change of employment

especially the one that says template design and documentation that it's a way to that is the way we have to create HTML templates in this case for example we have that I can

for the for loop amber will see that there are different control close structures like eve spade man I'm holders

up to this point we have seen how to create simple web applications returning HTML %HESITATION by constructing that HTML from templates and go

we need we

data

we're going to now start digging into more advanced by phone and flask features and the next one is going to be routed to create different routes for Arab