trail / twig
Twig templates for trail
dev-main / 0.1.x-dev
2026-09-20 20:13 UTC
Requires
- php: >=8.4
- trail/framework: ^0.1
- twig/twig: ^3.15
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is not auto-updated.
Last update: 2026-09-20 23:32:40 UTC
README
Twig templating language for trail framework. Cause i love twig and its great
install
composer require trail/twig
use
Create .twig files in the same template dir as the .php ones. By default .php will win over .twig if they have the same name/location. This is so installing twig won't just like... break the whole site. If you want to swap it just delete/rename the .php file and twig will take over
An example is View::render('pages/home') will use pages/home.php if it exists. Otherwise it'll go to pages/home.twig
{% extends '_layouts/_base.twig' %}
{% set title = 'hello' %}
{% block content %}
{% include '_components/breadcrumbs.twig' with {crumbs: [{label: 'home', url: url('home')}]} only %}
<h1>hi, {{ name }}</h1>
<a href="{{ url('pastebin') }}">pastes</a>
{% endblock %}
helpers
{{ url('hello', {name: 'cat'}) }}
{{ config('app.log.level') }}
{{ env('TRAIL_ENV') }}
{{ dir('storage') }}
{{ view('_components/nav') }}
config [trail/config/twig.php, optional]
return [
'*' => [
'cache' => '/tmp/twig',
'options' => ['charset' => 'utf-8'],
],
];
Cache defaults to storage/cache/twig, but like most everything else you can move that wherever you want
clear compiled templates
trail/trail twig::clear