mj-zana / view-twig
Twig templates for mj-zana/view
v2.1.0
2026-10-25 20:38 UTC
Requires
- php: ^8.5
- mj-zana/view: ^2.1
- twig/twig: ^3.14
Requires (Dev)
- mj-zana/translation: ^2.1
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^11.5
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Twig templates for mj-zana/view.
composer require mj-zana/view-twig
Register TwigServiceProvider together with ViewServiceProvider. Templates
then end in .html.twig, in the same folders: templates/ and each module's
Resources/views/, under the module's name.
{% extends 'layouts/site' %}
{% block content %}
<h1>{{ heading }}</h1>
<a href="{{ url('contact') }}">{{ 'nav.contact'|t }}</a>
<form method="post">{{ csrf_field('contact') }}</form>
{% endblock %}
- Names: the extension is optional:
View::make('pages/about'),{% include '@Contact/form' %}. - Escaping: autoescape is
html.Markupvalues and safe helpers such ascsrf_field()are not escaped. - Helpers: every view helper is a Twig function, and
tis also a filter. - Cache: in production, compiled templates are cached in
view.cache(defaultvar/cache/twig). Elsewhere, templates recompile when they change. - Twig extensions: add them in a provider's
boot()throughTwig\Environment.
License
MIT