Templates
The documentation is constantly evolving and updated alongside the project's progress. Since it is developed in parallel with the code, some sections may temporarily refer to earlier versions of the system-these are gradually adapted to the current state of the application. If you notice any outdated information, please report it or open an Issue / Pull Request.
Documentation
# Templates
DBM's view layer uses .phtml templates. The framework compiler supports a small directive syntax for output, PHP expressions, includes, blocks, and layout inheritance. BaseController::render() is the typical HTML entry point.
# Render with data
return $this->render('home/index.phtml', [
'title' => 'Home',
'user' => $user,
]);
In a template, {{ expression }} prints an escaped value and {% ... %} marks a template directive or PHP expression supported by the configured compiler:
<h1>{{ $title }}</h1>
{% if ($user): %}
<p>Welcome, {{ $user->name }}</p>
{% endif %}
Use the raw filter only for trusted, deliberately prepared HTML. Escaping output does not replace authorization or input validation.
# Includes and layout blocks
Include a partial where needed:
{% include '_include/footer.phtml' %}
A layout can yield named blocks and a child template can define them:
{% extends 'base.phtml' %}
{% block content %}
<h1>{{ $title }}</h1>
{% endblock %}
<main>{% yield content %}</main>
The compiler also supports passing a context to includes and filters; see Template Engine for syntax and configuration details. $this is a template runtime/helper object, not the original controller instance. Available methods depend on the registered view features and application configuration.
The view engine can be replaced by another implementation at the application composition layer, provided controller rendering and the response contract remain compatible.