Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tomasvotruba/torch

Smoke testing of TWIG templates
https://github.com/tomasvotruba/torch

php static-analysis symfony templates twig

Last synced: 1 day ago
JSON representation

Smoke testing of TWIG templates

Awesome Lists containing this project

README

        

# Torch

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

[![Downloads](https://img.shields.io/packagist/dt/tomasvotruba/torch.svg?style=flat-square)](https://packagist.org/packages/tomasvotruba/torch/stats)


## Install

```bash
composer require tomasvotruba/torch --dev
```


## Usage

1. Create `torch.php` in your project root:

```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;
```

In this file, you can override existing twig functions:

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


2. Run torch your twig files directories:

```php
vendor/bin/torch run templates
```


## Behind Scenes

* https://tomasvotruba.com/blog/twig-smoke-rendering-why-do-we-even-need-it/
* https://tomasvotruba.com/blog/twig-smoke-rendering-journey-of-fails/
* https://tomasvotruba.com/blog/twig-smoke-rendering-fortune-favors-the-bold

Happy coding!