stillat / antlers-layouts
Fund package maintenance!
JohnathonKoster
Installs: 1 109
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: ^8.0
- statamic/cms: ^4.57 || ^5
Requires (Dev)
- laravel/pint: ^1.8
- mockery/mockery: ^1.2.3
- orchestra/testbench: ^7.0 || ^8.0 || ^9
This package is auto-updated.
Last update: 2024-11-11 21:06:59 UTC
README
Antlers Layouts is a Statamic addon that allows you to extend arbitrary layouts and pass data to your template's layouts.
Features
This addon:
- Allows you to extend arbitrary layouts from within your Antlers templates;
- Pass data to layouts from templates
How to Install
You can install this addon by running the following command from your project root:
composer require stillat/antlers-layouts
How to Use
The Antlers Layouts addon provides a single layout
Tag that allows you to extend arbitrary layouts and pass data to your template's layout.
The recommended way to organize multiple layouts within your Statamic project is to create a new folder at the following locations to contain your extra layout templates:
resources/views/layouts/
Assuming we had a file named resources/views/layouts/custom-layout.antlers.html
, we could use dynamically swap to this layout by including the following Antlers tag anywhere in our template:
{{ layout:layouts/custom-layout }}
By including this Tag, Antlers will now utilize the resources/views/layouts/custom-layout.antlers.html
file as our layout instead of the normal resources/views/layout.antlers.html
file.
We can use the layout:share
Tag to pass data to our Antlers layout files:
{{ layout:share variable_one="Value One" variable_two="Another value" :variable_three="title" /}}
It is important to note that the
layout:share
Tag will only pass custom variables to the standardlayout.antlers.html
template file, and custom layouts located within theresources/views/layouts/
folder.
Our custom variables created using the layout:share
Tag will now be available to us in our layout file like any other variable:
{{# Inside the layout template. #}} {{ variable_one }} {{ variable_two }} {{ variable_three }}
License
Antlers Layouts is free software released under the MIT License.