A php based template generator for files of every language. Pass a directory with template files, pass variables for template and create files in a given destination.
composer require pureware/template-generator
First pass the template variables with values to the twig parser
$parser = new Pureware\TemplateGenerator\Parser\TwigParser();
$parser->setTemplateData(
[
'data' => 'value',
]
);
Then create a virtual files Tree. You can create a new directory or leave it empty.
$treeBuilder = new Pureware\TemplateGenerator\TreeBuilder\TreeBuilder();
$treeBuilder->skip(['path/to/file/or/dirrectory']); //skip file or dir
$files = $treeBuilder->buildTree('../templates', 'YourNewDirectory'); // your templates
Pass the files and directories you want to create to the template generator
$generator = new DirectoryGenerator('destination/path/for/your/new/files/YourNewDirectory, $parser);
$generator->setForce(true); //allows you to overrite already existing files
$generator->generate($files);
Basically you can use default twig syntax
The twig environment uses the symfony UnicodeString
extension: https://github.com/twigphp/string-extra
camelCase
{{value|u.camel}}
PascalCase
{{value|u.camel.title}}
Snake
{{value|u.snake}}