2 /* vim: set expandtab sw=4 ts=4 sts=4 ft=php: */
4 declare(strict_types=1);
6 if (! defined('ROOT_PATH')) {
7 define('ROOT_PATH', dirname(__DIR__) . DIRECTORY_SEPARATOR);
10 $tmpDir = ROOT_PATH . 'twig-templates';
12 /* Read replacements file */
13 $replacements = json_decode(file_get_contents($tmpDir . '/replace.json'), true);
16 $filesList = file_get_contents($tmpDir . '/filesList');
18 $options = getopt('', ['reverse::']);
20 foreach ($replacements as $templateName => $data) {
21 if (isset($options['reverse'])) {
22 $filesList = str_replace($data[0], $templateName, $filesList);
24 $filesList = str_replace($templateName, $data[0], $filesList);
28 /* Write back files list */
29 file_put_contents($tmpDir . '/filesList', $filesList);