...

/

Views in Adonis.

Views in Adonis.

What is a View in AdonisJS

A view is what a user sees or what gets rendered to HTML. Adonis uses edge templating to render views. Although core business logic is kept out of views, they still use logical expressions in form of tags to manipulate and control data. We can see a good example in the quiz-end.edge view of our app.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Game End</title>
    {{ style('css/bootstrap.min') }}
</head>
<body>
    <main class="container">
        <h1>{{decode(title)}}</h1>

        <div>
            @each(quiz in quizes)
            <div>
                <h3>{{decode(quiz.question)}}</h3>
                @each(answer in quiz.answers)
                <div class="d-flex align-items-baseline">
                    @if(answer.isCorrect)
                        <img width="15" src="/icons/check.svg" alt="checkmark">
                    @else
                        <img width="15" src="/icons/x.svg" alt="checkmark">
                    @endif
                    <p class="ms-2">{{decode(answer.text)}}</p>
                </div>
                @endeach
            </div>
            @endeach
        </div>

        <div class="my-4">
            <a href="/" class="btn btn-primary" type="submit">Play Again</a>
        </div>
    </main>
</body>
</html>

We render a check (✅) image if the ...

Access this course and 1400+ top-rated courses and projects.