{"id":17275103,"url":"https://github.com/daun/laravel-latte","last_synced_at":"2025-04-14T09:11:40.889Z","repository":{"id":224612726,"uuid":"748771391","full_name":"daun/laravel-latte","owner":"daun","description":"Use Latte templates in Laravel views","archived":false,"fork":false,"pushed_at":"2025-03-07T09:44:52.000Z","size":114,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-27T22:37:01.605Z","etag":null,"topics":["laravel","latte","template-engine","view"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/daun.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-26T18:20:30.000Z","updated_at":"2025-03-23T02:15:37.000Z","dependencies_parsed_at":"2024-02-26T22:10:05.443Z","dependency_job_id":"0da0fb92-b711-43b4-94e6-7a692883fc70","html_url":"https://github.com/daun/laravel-latte","commit_stats":null,"previous_names":["daun/laravel-latte"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daun%2Flaravel-latte","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daun%2Flaravel-latte/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daun%2Flaravel-latte/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daun%2Flaravel-latte/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/daun","download_url":"https://codeload.github.com/daun/laravel-latte/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248852181,"owners_count":21171842,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["laravel","latte","template-engine","view"],"created_at":"2024-10-15T08:55:26.932Z","updated_at":"2025-04-14T09:11:40.832Z","avatar_url":"https://github.com/daun.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel Latte\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/daun/laravel-latte.svg)](https://packagist.org/packages/daun/laravel-latte)\n[![Test Status](https://img.shields.io/github/actions/workflow/status/daun/laravel-latte/ci.yml?label=tests)](https://github.com/daun/laravel-latte/actions/workflows/ci.yml)\n[![Code Coverage](https://img.shields.io/codecov/c/github/daun/laravel-latte)](https://app.codecov.io/gh/daun/laravel-latte)\n[![License](https://img.shields.io/github/license/daun/laravel-latte.svg)](https://github.com/daun/laravel-latte/blob/master/LICENSE)\n\nAdd support for the [Latte](https://latte.nette.org) templating engine in [Laravel](https://laravel.com) views.\n\n## Features\n\n- Render `.latte` views\n- Latte engine configurable via facade\n- Translation provider to access localized messages\n- Laravel-style path resolution when including partials\n- Extensive test coverage\n\n## Installation\n\n``` bash\ncomposer require daun/laravel-latte\n```\n\n## Requirements\n\n- PHP 8.1+\n- Laravel 9/10/11\n\n## Usage\n\nInstalling the composer package will automatically register a Service Provider with your Laravel app.\nYou can now render Latte files like you would any other view. The example below will render the\nview at `resources/views/home.latte` using Latte.\n\n```php\nRoute::get('/', function() {\n    return view('home');\n});\n```\n\n## Configuration\n\nThe package will read its configuration from `config/latte.php`. Use Artisan to publish and\ncustomize the default config file:\n\n```sh\nphp artisan vendor:publish --provider=\"Daun\\LaravelLatte\\ServiceProvider\"\n```\n\n## Localization\n\nThe package includes a custom translator extension that acts as a bridge to Laravel's translation\nservice. It allows using any translations registered in your app to be used in Latte views, using\neither the `_` tag or the `translate` filter:\n\n```latte\n{_'messages.welcome'}\n{('messages.welcome'|translate)}\n```\n\nYou can pass in parameters as usual:\n\n```latte\n{_'messages.welcome', [name: 'Adam']}\n{('messages.welcome'|translate:[name: 'Adam'])}\n```\n\nTranslate using a custom locale by passing it after or in place of the params:\n\n```latte\n{_'messages.welcome', [name: 'Mary'], 'fr'}\n{_'messages.welcome', 'fr'}\n```\n\nPluralization works using the `transChoice` filter.\n\n```latte\n{('messages.apples'|transChoice:5)}\n```\n\n## Path resolution\n\nThe package includes a custom loader that allows including partials from subdirectories using\nLaravel's dot notation to specify folders.\n\n```latte\n{* resolves to /resources/views/partials/slideshow/image.latte *}\n\n{include 'partials.slideshow.image'}\n```\n\nTo specifically include files relative to the current file, prefix the path with `./` or `../`:\n\n```latte\n{include './image.latte'}\n```\n\n## Default layout\n\nIf you require a common layout file for all views, you can define a default layout in\n`config/latte.php`. Any views without a specifically set layout will now be merged into that layout.\n\n```php\n[\n    // /resources/views/layouts/default.latte\n    'default_layout' =\u003e 'layouts.default'\n]\n```\n\n## Configuring Latte\n\n### Extensions\n\nTo extend Latte and add your own tags, filters and functions, you can use the `extensions` array\nin `config/latte.php` to supply a list of Latte extensions to register automatically.\n\n```php\n[\n    'extensions' =\u003e [\n        \\App\\View\\Latte\\MyExtension::class\n    ]\n]\n```\n\n### Facade\n\nYou can also directly access and configure the Latte engine instance from the `Latte` facade.\nModify its config, add custom filters, etc.\n\n```php\nuse Daun\\LaravelLatte\\Facades\\Latte;\nuse Illuminate\\Support\\ServiceProvider;\n\nclass AppServiceProvider extends ServiceProvider\n{\n    public function boot()\n    {\n        Latte::addFilter('plural', fn($str) =\u003e Str::plural($str));\n    }\n}\n```\n\n### Events\n\nIf you need to be notified when the Latte engine is created, listen for the `LatteEngineCreated`\nevent to receive and customize the returned engine instance.\n\n```php\nuse Daun\\LaravelLatte\\Events\\LatteEngineCreated;\nuse Illuminate\\Support\\ServiceProvider;\n\nclass AppServiceProvider extends ServiceProvider\n{\n    public function register()\n    {\n        Event::listen(function (LatteEngineCreated $event) {\n            $event-\u003eengine-\u003esetAutoRefresh(true);\n        });\n    }\n}\n```\n\n## License\n\n[MIT](https://opensource.org/licenses/MIT)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaun%2Flaravel-latte","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdaun%2Flaravel-latte","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaun%2Flaravel-latte/lists"}