smalldb/template-sloth

基于插槽的模板扩展

安装: 18

依赖者: 0

建议者: 0

安全: 0

星标: 1

关注者: 2

分支: 1

类型:symfony-bundle

dev-master 2021-02-11 23:28 UTC

This package is auto-updated.

Last update: 2024-09-12 07:32:16 UTC


README

基于插槽的模板扩展。

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

...

安装

使用Composer

composer require smalldb/template-sloth

Symfony的config.yml — 添加sloth服务,它将自动注册到Twig中

services:
        sloth:
                class: Smalldb\TemplateSloth\Sloth
                arguments: [ '@twig' ]

故障排除

错误:意外的"slot"标签(期望"…"标签的结束标签,该标签定义在行…附近)在…

这意味着Sloth没有安装Twig扩展。您的依赖注入容器配置正确吗?

用法

$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 %}

文档

https://smalldb.org/doc/template-sloth/master/

许可证

大部分代码是在Apache 2.0许可证下发布的。有关详细信息,请参阅LICENSE文件。

贡献指南

项目的主要仓库托管在https://git.frozen-doe.net/smalldb/template-sloth,您可以随时在那里提交问题或创建合并请求。