Smoke testing of TWIG templates

0.3.9 2024-01-29 18:09 UTC

README

...when you need to cover your Twig with smoke.

Downloads


Install

composer require tomasvotruba/torch --dev

Usage

  1. Create torch.php in your project root:
use Twig\Environment;

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

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

return $environment;

In this file, you can override existing twig functions:

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

  1. Run torch your twig files directories:
vendor/bin/torch run templates

Behind Scenes

Happy coding!