Files
ops-Gazelle/bin/twig-parse
2025-02-24 14:37:56 +01:00

24 lines
561 B
PHP
Executable File

#! /usr/bin/env php
<?php
require_once(__DIR__ . '/../lib/bootstrap.php');
$twig = Gazelle\Util\Twig::factory(new \Gazelle\Manager\User());
// there is no dump() in production
$twig->addFunction(new \Twig\TwigFunction('dump', function ($value) { return ''; }));
$exitcode = 0;
array_shift($argv);
foreach ($argv as $arg) {
try {
$twig->parse($twig->tokenize(new \Twig\Source(file_get_contents($arg), $arg)));
} catch (\Twig\Error\SyntaxError $e) {
echo "$arg: {$e->getMessage()}\n";
$exitcode = 1;
}
}
exit($exitcode);