From 0b9db7e6a0f23920ad5dfb8b6b0bc879a2955bec Mon Sep 17 00:00:00 2001 From: Pavel Shevaev Date: Tue, 14 Nov 2023 23:20:17 +0300 Subject: [PATCH] Adding convenience codegen(..) function --- src/codegen.inc.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/codegen.inc.php b/src/codegen.inc.php index f2d1998..7f0eb9d 100644 --- a/src/codegen.inc.php +++ b/src/codegen.inc.php @@ -2,6 +2,18 @@ namespace metagen_php; use Exception; +function codegen(?string $cache_dir, \mtgMetaInfo $meta, array $options = []) : string +{ + $twig = get_twig(); + + if(!empty($cache_dir)) + $twig->setCache($cache_dir); + + $options['meta'] = $meta; + + return $twig->render('codegen_bundle.twig', $options); +} + function get_twig(array $inc_path = []) { array_unshift($inc_path, __DIR__ . "/../tpl/");