Tag: twig
-
Symfony 5+ Twig templates don’t forget to call the parent
Twig templates use inheritance and allows you to create named sections like this. <!doctype html> <html lang=”en”> <head> <meta charset=”UTF-8″> <meta name=”viewport” content=”width=device-width, initial-scale=1, shrink-to-fit=no”> <link rel=’icon’ href=”{{ asset(‘images/favicon.ico’) }}” type=’image/x-icon’ > {% block head_extra %}{% endblock %} <title>{% block title %}{{ title }}{% endblock %}</title> {% block stylesheets %} {# ‘app’ must match the…
-
Symfony 5+ check if user is logged in inside a twig template
Often you may need to know whether a user is logged in or not inside a template to show or not show something. For example you might want to show links to login or register if a user is not logged in but show a link to logout if the user is logged in. To…