Given the base template defines a block and the child template overrides it, what will the final rendered HTML output be?
{% raw %}
<!-- base.html -->
<html>
<body>
{% block content %}Base Content{% endblock %}
</body>
</html>
<!-- child.html -->
{% extends 'base.html' %}
{% block content %}Child Content{% endblock %}
{% endraw %}Remember that child templates replace blocks defined in the base template.
The child template overrides the content block, so the rendered output shows "Child Content" inside the body.
Identify the correct syntax to override a block named header in a child template.
Blocks must start with {% block name %} and end with {% endblock %}.
Option C uses the correct Jinja2 syntax for defining and overriding blocks. Options A, B, and D have invalid syntax.
Examine the child template code below. Why does it cause a TemplateSyntaxError when rendering?
{% raw %}
{% extends 'base.html' %}
{% block content %}
<p>Welcome!</p>
{% endblock content %}
{% endraw %}Check the syntax rules for ending blocks in Jinja2.
Jinja2 requires the block to be closed with {% endblock %} only. Adding the block name after endblock causes a syntax error.
Given the following base and child templates, what will be the rendered output?
{% raw %}
<!-- base.html -->
<html>
<body>
{% block main %}
Main Base
{% block sidebar %}Sidebar Base{% endblock %}
{% endblock %}
</body>
</html>
<!-- child.html -->
{% extends 'base.html' %}
{% block main %}
Main Child
{% block sidebar %}Sidebar Child{% endblock %}
{% endblock %}
{% endraw %}Remember that nested blocks can be overridden independently in child templates.
The child template overrides both main and the nested sidebar block, so both show the child's content.
Choose the correct statement about how block overriding works in Flask Jinja2 templates.
Think about how to include base block content when overriding.
In Jinja2, overriding a block replaces the base block content entirely unless super() is used to include the original content. Blocks can be nested and do not cause errors if not overridden.