对TWIG模板进行烟雾测试

0.3.9 2024-01-29 18:09 UTC

README

...当你需要给你的Twig覆盖烟雾时。

Downloads


安装

composer require tomasvotruba/torch --dev

用法

  1. 在你的项目根目录创建 torch.php
use Twig\Environment;

require_once __DIR__ . '/vendor/autoload.php';

// create instance of Environment with everything needed for smoke render
$environment = new Environment(...);

return $environment;

在这个文件中,你可以覆盖现有的twig函数

// override twig functions you need
StaticParameterProvider::set('overrideFunctions', [
    // provide static value for dynamic function
    'baseTemplate' => function () {
        return DummyTheme::LAYOUT_NAME;
    },
]);

  1. 运行torch命令在你的twig文件目录中
vendor/bin/torch run templates

幕后

快乐编码!