Render a simple template

This commit is contained in:
Oliver Davies 2023-01-19 18:37:13 +00:00
parent c476543f5c
commit 31614e0f58
5 changed files with 82 additions and 67 deletions

View file

@ -9,7 +9,10 @@ use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Yaml\Yaml;
use Twig\Environment;
use Twig\Loader\FilesystemLoader;
#[AsCommand(
description: 'Build configuration files',
@ -25,8 +28,11 @@ final class BuildConfigurationCommand extends Command
$io = new SymfonyStyle($input, $output);
$io->info("Building configuration for {$buildYaml['name']}.");
// Parse its contents.
// Generate the appropriate configuration files.
$twig = new Environment(new FilesystemLoader([__DIR__.'/../../../templates']));
$output = $twig->render('test.twig', $buildYaml);
$fs = new Filesystem();
$fs->dumpFile('test.txt', $output);
//
return Command::SUCCESS;
}