Template Sloth
Template Sloth

Slot-based template extension.

See https://smalldb.org/template-sloth/

...

Installation

Using Composer:

1 {
2  "require": {
3  "smalldb/template-sloth": "dev-master"
4  },
5 }

Symfony's config.yml — add sloth service, it will register into Twig automatically:

1 services:
2  sloth:
3  class: Smalldb::TemplateSloth::Sloth
4  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();
1 {% if 'content' is empty_slot %}
2  No content available.
3 {% else %}
4  {% slot 'content' %}
5 {% 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.