Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Title: Twig template error – Missing closing tag for loop

#[Route('/instructeur/lessen')]
class LessenController extends AbstractController
{
    #[Route('/', name: 'app_lessen_index', methods: ['GET'])]
    public function index(LessenRepository $lessenRepository){
        $vandaag = new \DateTime() ;
        $lessen = $lessenRepository->findBy(["datum" => $vandaag ]);
        return $this->render('/instructeur/lessen/index.html.twig', [
            'lessen' => $lessen
        ]);
    }
{% for lessen in lessen %}
    <tr>
        <td>{{ lessen.id }}</td>
        <td>{{ lessen.status }}</td>
        <td>{{ lessen.ophaalLocatie }}</td>
        <td>{{ lessen.lesdoel }}</td>
        <td>{{ lessen.naamLeerling }}</td>
        <td>{{ lessen.naamInstructeur }}</td>
        <td>{{ lessen.datum ? lessen.datum|date('Y-m-d') : '' }}</td>
        <td>{{ lessen.prijs }}</td>
        <td>
            <a href="{{ path('app_lessen_show', {'id': lessen.id}) }}">show</a>
            <a href="{{ path('app_lessen_edit', {'id': lessen.id}) }}">edit</a>
        </td>
    </tr>
{% else %}
    <p>No lessons found.</p>

Hello Stack Overflow community, Iam a new developer and i’m encountering an issue with a Twig template where I seem to be missing a closing tag for a loop. I’ve been trying to debug it, but I can’t seem to find the exact problem. Hope u guys can help me 🙂

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Hi there new developer the issue you are encountering with the temlpate misses indeed a for loop for lessen. you can try this?

Please update me for if it works

#[Route('/instructeur/lessen')]
class LessenController extends AbstractController
{
    #[Route('/', name: 'app_lessen_index', methods: ['GET'])]
    public function index(LessenRepository $lessenRepository){
        $vandaag = new \DateTime() ;
        $lessen = $lessenRepository->findBy(["datum" => $vandaag ]);
        return $this->render('/instructeur/lessen/index.html.twig', [
            'lessen' => $lessen
        ]);
    }
TWIG:   {% for lessen in lessen %}
            <tr>
                <td>{{ lessen.id }}</td>
                <td>{{ lessen.status }}</td>
                <td>{{ lessen.ophaalLocatie }}</td>
                <td>{{ lessen.lesdoel }}</td>
                <td>{{ lessen.naamLeerling }}</td>
                <td>{{ lessen.naamInstructeur }}</td>
                <td>{{ lessen.datum ? lessen.datum|date('Y-m-d') : '' }}</td>
                <td>{{ lessen.prijs }}</td>
                <td>
                    <a href="{{ path('app_lessen_show', {'id': lessen.id}) }}">show</a>
                    <a href="{{ path('app_lessen_edit', {'id': lessen.id}) }}">edit</a>
                </td>
            </tr>
        {% else %}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading