torch

Smoke testing of TWIG templates

OTHER License

Downloads
5.1K
Stars
2

Torch

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

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!