Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tomasvotruba/torch
Smoke testing of TWIG templates
https://github.com/tomasvotruba/torch
php static-analysis symfony templates twig
Last synced: 3 months ago
JSON representation
Smoke testing of TWIG templates
- Host: GitHub
- URL: https://github.com/tomasvotruba/torch
- Owner: TomasVotruba
- License: other
- Created: 2023-04-24T07:32:01.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-01-29T18:09:18.000Z (11 months ago)
- Last Synced: 2024-10-09T11:30:47.656Z (3 months ago)
- Topics: php, static-analysis, symfony, templates, twig
- Language: PHP
- Homepage: https://tomasvotruba.com/blog/twig-smoke-rendering-why-do-we-even-need-it/
- Size: 1000 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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-boldHappy coding!