Search by

trail / twig

dodgycoffee

Twig templates for trail

Package info

source.tube/brindly/trail-twig

Issues

Type:trail-addon

pkg:composer/trail/twig

Statistics

Installs: 3

Dependents: 0

Suggesters: 0

dev-main / 0.1.x-dev 2026-09-22 07:54 UTC

This package is auto-updated.

Last update: 2026-09-22 07:54:43 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/app.php, optional]

Lives in the twig section of app.php

return [
    '*' => [
        'twig' => [
            'templateCaching' => true,
            'cache' => '/tmp/twig',
            'options' => ['charset' => 'utf-8'],
        ],
    ],
    'dev' => ['twig' => ['templateCaching' => false]],
];

Cache defaults to storage/cache/twig, but like most everything else you can move that wherever you want. Set templateCaching to false in order to disable it for debugging

clear compiled templates

trail/trail twig::clear