SAND-framework/data/doc-prince-book-generation/doc/sand/Contents/04.a. Les vues Twig.md

2.2 KiB

#Les vues Twig

Elles sont chargées dans cette ordre:

  • application/include/vues/system
  • application/include/vues/layout
  • application/include/vues/view

ainsi la vue standard peut étendre de application/include/vues/layout/body.html.twig


{% block body %}
    <!-- Body Inner -->
        <section id="page-content">
            <div class="container">

                <!--Alerts-->
                {% if $_SESSION['alerts'] is defined %}
                    {% foreach $_SESSION['alerts'] as alert %}
                        <div class="alert alert-{{alert.type}} alert-dismissible fade show" role="alert">
                            <strong>{{alert.title}}</strong> {{alert.message}}.
                            <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
                        </div>
                    {% endforeach %}
                    {% endif %}
                <!--end: Alerts-->
                {% block content %}{% endblock %}

            </div>
        </section>
{% endblock %}}

qui étends de application/include/vues/system/system.html.twig

<!DOCTYPE html>
<html>
<head>
    {% block head %}
        <title>{{page_title}}</title>

        <meta name="viewport" content="width=device-width, initial-scale=1" />
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <meta name="author" content="" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="description" lang="fr" content="{{description}}"/>
        {% block top-css %}
            <link rel="stylesheet" href="{{ \MVC\Classe\Url::asset_rewrite('assets/bootstrap-5.0.0-beta1-dist/css/bootstrap.min.css')}}">
            <link rel="stylesheet" href="{{ \MVC\Classe\Url::asset_rewrite('assets/css/custom.css')}}">
        {% endblock %}
    {% endblock %}
</head>
<body>

{% block top-javascript %}{% endblock %}

{% block body %}{% endblock %}

{% block bottom-javascript %}
<script src="{{ \MVC\Classe\Url::asset_rewrite('assets/bootstrap-5.0.0-beta1-dist/js/bootstrap.min.js')}}"></script>
<script src="{{ \MVC\Classe\Url::asset_rewrite('assets/js/custom.js')}}"></script>
{% endblock %}
</body>
</html>