lelyfoto/twig-instanceof 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

lelyfoto/twig-instanceof

最新稳定版本:v1.2

Composer 安装命令:

composer require lelyfoto/twig-instanceof

包简介

Adds InstanceOf Expression as Twig Extension

README 文档

README

Package version PHP version License

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

  1. Install this Symfony bundle with composer:
    composer require lelyfoto/twig-instanceof
  2. 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

GitHub 信息

  • Stars: 7
  • Watchers: 1
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-02-11