nucleos/twig-extensions

为twig提供有用的扩展。

3.3.0 2024-08-14 16:28 UTC

README

Latest Stable Version Latest Unstable Version License

Total Downloads Monthly Downloads Daily Downloads

Continuous Integration Code Coverage Type Coverage

为twig提供有用的扩展。

安装

打开命令行控制台,进入您的项目目录,然后执行以下命令以下载此库的最新稳定版本:

composer require nucleos/twig-extensions

Symfony 使用

如果您想在symfony中使用此库,可以使用桥梁。

启用 Bundle

然后,通过将其添加到项目中 config/bundles.php 文件中注册的包列表中来启用 Bundle

// config/bundles.php

return [
    // ...
    Nucleos\Twig\Bridge\Symfony\Bundle\NucleosTwigBundle::class => ['all' => true],
];

Twig 文本垃圾邮件保护

Twig 过滤器 spamsecure 替换所有点和 @ 符号。

{# Replace plain text #}
{{ text|spamsecure }}

{# Replace rich text mails #}
{{ htmlText|spamsecure(true) }}

配置 Bundle

创建一个名为 nucleos_twig.yaml 的配置文件

# config/packages/nucleos_twig.yaml

nucleos_twig:
    secure:
        mail:
            at_text:   [ ' [AT] ', ' (AT) ', ' [ÄT] ' ]
            dot_text:  [ ' [DOT] ', ' (DOT) ', ' [.] ' ]

许可证

此库受 MIT 许可证 的约束。