smalldb / template-sloth
基于插槽的模板扩展
dev-master
2021-02-11 23:28 UTC
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-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,您可以随时在那里提交问题或创建合并请求。