You’re reading the v0.1 development preview. APIs may change.
~ 1 min readUpdated 2026-10-29

Views & templates

Elang uses Twig to render HTML on the server. Your frontend can remain plain HTML, CSS, and JavaScript.

Render a view

use Elang\View\View;

$router->get('/', fn (View $view) =>
    $view->render('home', ['title' => 'My application'])
);

This loads resources/views/home.twig. Pass an optional third argument to set an HTTP status.

Escape output

<h1>{{ title }}</h1>

HTML autoescaping and strict variable checks are enabled. Use |raw only for trusted, sanitized HTML. Do not mark user-supplied content as raw.

Layouts

{% extends "base.twig" %}
{% block content %}
  <h1>{{ title }}</h1>
{% endblock %}

Twig templates are compiled into the writable storage cache. CSS and JavaScript files belong in public/assets/. External files also fit the default Content Security Policy, which disallows inline scripts and styles.

Named route links

<a href="{{ route('posts.show', {id: 42}) }}">Read post</a>

Read the Twig documentation for inheritance, includes, filters, and template syntax.

Need a hand?

Check the troubleshooting guide, look up a term in the glossary, or work through the complete task board project.

Search Elang documentation

Start typing to find your next step.