TransWikia.com

Наследование в шаблонах twig не работает

Stack Overflow на русском Asked by Antony Lapitskiy on November 27, 2021

После наследования base весь остальной темплейт не отображается.

base.html.twig

<!doctype html>
<html lang="en">
<body>
   <nav class="navbar navbar-expand-lg navbar-dark navbar-bg mb-5">
     <div class="collapse navbar-collapse" id="navbarNavDropdown">
       <ul class="navbar-nav ml-auto">
        <li class="nav-item">
            <a style="color: #fff;" class="nav-link" href="{{ path('app_login') 
          }}">Login</a>
        </li>
        {#
        <li class="nav-item dropdown" style="margin-right: 75px;">
            <a class="nav-link dropdown-toggle" href="http://example.com" 
             id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria- 
              expanded="false">
              <img class="nav-profile-img rounded-circle" src="{{ asset('images/astronaut- 
               profile.png') }}">
            </a>
            <div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
                <a class="dropdown-item" href="#">Profile</a>
                <a class="dropdown-item" href="#">Create Post</a>
                <a class="dropdown-item" href="#">Logout</a>
            </div>
        </li>
        #}
    </ul>
    </div>
    </nav></body></html>

login.html.twig

    {% extends 'base.html.twig' %}

    {% block title %}Log in!{% endblock %}

    {% block body %}
    <form method="post">
     
    {% if error %}
    <div class="alert alert-danger">{{ error.messageKey|trans(error.messageData, 'security') }}</div>
{% endif %}

{% if app.user %}
    <div class="mb-3">
        You are logged in as {{ app.user.username }}, <a href="{{ path('app_logout') }}">Logout</a>
    </div>
{% endif %}

<h1 class="h3 mb-3 font-weight-normal">Please sign in</h1>
<label for="inputEmail">Email</label>
<input type="email" value="{{ last_username }}" name="email" id="inputEmail" class="form-control" required autofocus>
<label for="inputPassword">Password</label>
<input type="password" name="password" id="inputPassword" class="form-control" required>

<input type="hidden" name="_csrf_token"
       value="{{ csrf_token('authenticate') }}"
>

<div class="checkbox mb-3">
    <label>
        <input type="checkbox" name="_remember_me"> Remember me
    </label>
</div>

<button class="btn btn-lg btn-primary" type="submit">
    Sign in
</button>
</form> 

   {% endblock %}

   [![https://i.stack.imgur.com/MzML4.png][1]][1]

https://i.stack.imgur.com/MzML4.png

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP