Skip to content

pureware/template-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHP based template generator with twig templates

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.

Install

composer require pureware/template-generator

General Usage

Twig Parser

First pass the template variables with values to the twig parser

$parser = new Pureware\TemplateGenerator\Parser\TwigParser();
$parser->setTemplateData(
    [
        'data' => 'value',
    ]
);

Tree builder

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

Templates generator

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);

Templates

Basically you can use default twig syntax

Change string case

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}}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages