Download the PHP package daun/laravel-latte without Composer
On this page you can find all versions of the php package daun/laravel-latte. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download daun/laravel-latte
More information about daun/laravel-latte
Files in daun/laravel-latte
Package laravel-latte
Short Description Use Latte templates in Laravel views
License MIT
Homepage https://github.com/daun/laravel-latte
Informations about the package laravel-latte
Laravel Latte
Add support for the Latte templating engine in Laravel views.
Features
- Render
.latte
views - Latte engine configurable via facade
- Translation provider to access localized messages
- Laravel-style path resolution when including partials
- Extensive test coverage
Installation
Requirements
- PHP 8.1+
- Laravel 9/10/11
Usage
Installing the composer package will automatically register a Service Provider with your Laravel app.
You can now render Latte files like you would any other view. The example below will render the
view at resources/views/home.latte
using Latte.
Configuration
The package will read its configuration from config/latte.php
. Use Artisan to publish and
customize the default config file:
Localization
The package includes a custom translator extension that acts as a bridge to Laravel's translation
service. It allows using any translations registered in your app to be used in Latte views, using
either the _
tag or the translate
filter:
You can pass in parameters as usual:
Translate using a custom locale by passing it after or in place of the params:
Pluralization works using the transChoice
filter.
Path resolution
The package includes a custom loader that allows including partials from subdirectories using Laravel's dot notation to specify folders.
To specifically include files relative to the current file, prefix the path with ./
or ../
:
Default layout
If you require a common layout file for all views, you can define a default layout in
config/latte.php
. Any views without a specifically set layout will now be merged into that layout.
Configuring Latte
Extensions
To extend Latte and add your own tags, filters and functions, you can use the extensions
array
in config/latte.php
to supply a list of Latte extensions to register automatically.
Facade
You can also directly access and configure the Latte engine instance from the Latte
facade.
Modify its config, add custom filters, etc.
Events
If you need to be notified when the Latte engine is created, listen for the LatteEngineCreated
event to receive and customize the returned engine instance.