Adding convenience codegen(..) function
This commit is contained in:
parent
8cf73800d4
commit
7bc42031ae
|
@ -2,7 +2,23 @@
|
|||
namespace metagen_cs;
|
||||
use Exception;
|
||||
|
||||
function get_twig(array $inc_path = [])
|
||||
function codegen(?string $cache_dir, \mtgMetaInfo $meta, array $options = []) : string
|
||||
{
|
||||
$twig = get_twig();
|
||||
|
||||
if(!empty($cache_dir))
|
||||
$twig->setCache($cache_dir);
|
||||
|
||||
$twig->addGlobal('meta', $meta);
|
||||
|
||||
$options['meta'] = $meta;
|
||||
if(!isset($options['namespace']))
|
||||
$options['namespace'] = 'BitGames.Autogen';
|
||||
|
||||
return $twig->render('codegen_bundle.twig', $options);
|
||||
}
|
||||
|
||||
function get_twig(array $inc_path = []) : \Twig\Environment
|
||||
{
|
||||
array_unshift($inc_path, __DIR__ . "/../tpl/");
|
||||
$loader = new \Twig\Loader\FilesystemLoader($inc_path);
|
||||
|
@ -19,7 +35,7 @@ function get_twig(array $inc_path = [])
|
|||
return $twig;
|
||||
}
|
||||
|
||||
function supported_tokens()
|
||||
function supported_tokens() : array
|
||||
{
|
||||
return [
|
||||
'POD',
|
||||
|
|
Loading…
Reference in New Issue