Search by

mj-zana / view-twig

mjnable

Twig templates for mj-zana/view

Package info

github.com/mjnable/zana-view-twig

pkg:composer/mj-zana/view-twig

Statistics

Installs: 2

Dependents: 0

Suggesters: 1

Stars: 0

Open Issues: 0

v2.1.0 2026-10-25 20:38 UTC

This package is auto-updated.

Last update: 2026-10-25 21:17:49 UTC


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. Markup values and safe helpers such as csrf_field() are not escaped.
  • Helpers: every view helper is a Twig function, and t is also a filter.
  • Cache: in production, compiled templates are cached in view.cache (default var/cache/twig). Elsewhere, templates recompile when they change.
  • Twig extensions: add them in a provider's boot() through Twig\Environment.

License

MIT