{% extends.. block body} is it standard to use or not?

Is it standard to use % extends, block body, end block like in the code below(copied from cs50 video) or is it better to just type out the whole template on each new page with exclamation mark in vs code?
(% extends "layout.html" %}

(%block body %)

<form action="/greet" method="get">
<input autocomplete="off" autofocus name="name" placeholder="Name" required type="text">
<input type="submit>
</form>

(% endblock %}
(% extends "layout.html" %}

(%block body %)

<form action="/greet" method="get">
<input autocomplete="off" autofocus name="name" placeholder="Name" required type="text">
<input type="submit>
</form>

(% endblock %}
3 Replies
Joao
Joao•13mo ago
The idea is to avoid having to duplicate all that code on every page, so that if you change something you only have to do it in one place. So yes, use that 🙂
Jochem
Jochem•13mo ago
(also, only for future reference, no need to move this one, but this looks like twig? Which is a #back-end templating language, so please post any future questions there right away 🙂 There's no question too small to not go in the appropriate channel) and to add to what Joao said, yup, that's the entire point of templating and using extends
goky chan, plebku
goky chan, plebkuOP•13mo ago
they used some flask in cs50, my bad, thanks
Want results from more Discord servers?
Add your server