lelyfoto/twig-instanceof
最新稳定版本:v1.2
Composer 安装命令:
composer require lelyfoto/twig-instanceof
包简介
Adds InstanceOf Expression as Twig Extension
关键字:
README 文档
README
Adds InstanceOf Expression as Twig Extension. When you want to check for a specific type of variable in a twig template.
Prerequisites
- PHP 8.0+
- Symfony 5.4 or 6.x
- Twig 3.x
Installation
- Install this Symfony bundle with composer:
composer require lelyfoto/twig-instanceof
- Make sure the bundle is added to
config/bundles.php:return [ // ... Lelyfoto\Twig\InstanceOf\TwigInstanceOfBundle::class => ['all' => true], // ... ];
Usage
Important to note that when testing for a class that you must use quotes and escaping inside the twig templates.
{% if testObject is instanceof('\\Example\\TestInterface') %}
Do something with {{ testObject.show() }}
{% endif %}
Use without Symfony
use Twig\Environment; use Lelyfoto\Twig\InstanceOf\InstanceOfExtension; $twig = new Environment($loader); $twig->addExtension(new InstanceOfExtension());
统计信息
- 总下载量: 62.15k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 8
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-02-11