https://github.com/miyagi-dev/twig-laravel
https://github.com/miyagi-dev/twig-laravel
laravel twig twigjs
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/miyagi-dev/twig-laravel
- Owner: miyagi-dev
- Created: 2022-07-16T07:30:34.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2023-05-24T01:12:45.000Z (about 3 years ago)
- Last Synced: 2025-10-09T10:16:16.395Z (8 months ago)
- Topics: laravel, twig, twigjs
- Language: JavaScript
- Size: 1.26 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# @miyagi/twig-laravel
When using Laravel together with twig, this extension adds support for specific functionality to [@miyagi/core](https://npmjs.com/package/@miyagi/core).
## Features
### Laravel localization
In your templates, you might want to use translations with dot notation like `{{ trans('foo.bar') }}` or `{{ trans_choice('foo.bar', 2) }}`.
By using this extension, `miyagi` can load the translations from your localization files and use these.
By default the english localilzation files are used, which can be overwritten though.
See [Usage](#usage) for more information.
### twig
**NOTE:** If you need to add additional filters, functions or tags, please refer to the [_miyagi_ documentation](https://docs.miyagi.dev/configuration/extending-template-engine/).
#### Functions
This extension adds mocking to functions like `csrf_field` or `asset`, so `miyagi` does not throw an error when using these in your templates.
## Installation
```bash
npm i --save-dev @miyagi/twig-laravel
```
or
```bash
yarn add -D @miyagi/twig-laravel
```
### Usage
Add the extension to your `.miyagi.js` like this:
```js
module.exports = {
extensions: [[require('@miyagi/twig-laravel'), {
engine: Twig // optional, only necessary if you extended Twig in your configuration file,
// the `locales` object is optional, the values below are the default values
locales: {
rootFolder: "resources/lang",
lang: "en",
}
}]],
...
}
```