Jinja extend template layout block

We use extend to connect between templates. We use block both to mark the area that will be replaced and the content that will replace it.

from flask import Flask, render_template
app = Flask(__name__)

def index():
    return render_template('index.html')

def page():
    return render_template('page.html')

import app

def test_app():
    web = app.app.test_client()

    rv = web.get('/')
    assert rv.status == '200 OK'
    assert b'<a href="https://code-maven.com/">Code Maven</a>' in rv.data, 'footer'
    assert b'<title>Main page</title>' in rv.data, 'title'
    assert b'This is the content' in rv.data, 'content'

{% extends 'layouts/base.html' %}

{% block title -%}
Main page
{%- endblock %}

{% block content %}
This is the content
{% endblock %}

<!DOCTYPE html>
<html lang="en">
  <meta charset="utf-8">
  <meta name="viewport"
     content="width=device-width, initial-scale=1, user-scalable=yes">
  <title>{% block title %}{% endblock %}</title>
<a href="/">Home</a>

{% block content %}{% endblock %}

<a href="https://code-maven.com/">Code Maven</a>