smalldb / template-sloth
Slot-based template extension
Installs: 18
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 1
Type:symfony-bundle
Requires
- php: >=7.3
- symfony/http-foundation: >=3.2
- twig/twig: >=3.2
Requires (Dev)
- phpunit/phpunit: ^9.5
- smalldb/doc-tools: dev-master
- symfony/config: ^5.2
- symfony/dependency-injection: ^5.2
- symfony/http-kernel: ^5.2
This package is auto-updated.
Last update: 2024-12-12 08:04:32 UTC
README
Slot-based template extension.
See https://smalldb.org/template-sloth/
...
Installation
Using Composer:
composer require smalldb/template-sloth
Symfony's config.yml
— add sloth
service, it will register into Twig
automatically:
services: sloth: class: Smalldb\TemplateSloth\Sloth arguments: [ '@twig' ]
Troubleshooting
Error: Unexpected "slot" tag (expecting closing tag for the "…" tag defined near line …) in …
This means the Sloth did not install the Twig extension. Is your dependency injection container configured properly?
Usage
$sloth = $this->get('sloth'); $sloth->setLayout('layout.html.twig', [ 'user' => 'Alice']); $sloth->slot('content')->add(10, 'template.html.twig', [ 'foo' => 'bar' ]; $sloth->slot('content')->add(20, 'template.html.twig', [ 'foo' => 'foo' ]; return $sloth->response();
{% if 'content' is empty_slot %} No content available. {% else %} {% slot 'content' %} {% endif %}
Documentation
See https://smalldb.org/doc/template-sloth/master/
License
The most of the code is published under Apache 2.0 license. See LICENSE file for details.
Contribution guidelines
Project's primary repository is hosted at https://git.frozen-doe.net/smalldb/template-sloth, feel free to submit issues there or create merge requests.