From 720d36dd239c935ffd982597d2007fa96cc1a374 Mon Sep 17 00:00:00 2001 From: flashwave Date: Thu, 30 Jan 2025 11:46:04 +0000 Subject: [PATCH] Added script for rendering templates in console. --- src/MisuzuContext.php | 2 +- tools/render-tpl | 97 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+), 1 deletion(-) create mode 100755 tools/render-tpl diff --git a/src/MisuzuContext.php b/src/MisuzuContext.php index 6788356a..0c531cea 100644 --- a/src/MisuzuContext.php +++ b/src/MisuzuContext.php @@ -35,7 +35,7 @@ use RPCii\Server\HttpRpcServer; class MisuzuContext { public private(set) Dependencies $deps; - private TplEnvironment $templating; + public private(set) TplEnvironment $templating; public private(set) AuditLogData $auditLog; public private(set) CountersData $counters; diff --git a/tools/render-tpl b/tools/render-tpl new file mode 100755 index 00000000..dc12ec4e --- /dev/null +++ b/tools/render-tpl @@ -0,0 +1,97 @@ +#!/usr/bin/env php +config->getString('csrf.secret', 'soup'), '::1'); + +// neither should this i think, mostly done to make sure the url handler thing is available +$msz->createRouting(new HttpRequest('::1', true, 'XX', '1.1', 'GET', '/', [], [], new HttpHeaders([ + new HttpHeader('Host', $hostName), +]), null)); + +$msz->startTemplating(); + +$ctx = $msz->templating->load(implode(' ', array_slice($argv, $pathIndex))); + +foreach($tplArgs as $name => $value) + $ctx->setVar($name, $value); + +// things expect this to be defined which is also a bit yucky +if(!defined('MSZ_TPL_RENDER')) + define('MSZ_TPL_RENDER', microtime(true)); + +echo $ctx->render();