summaryrefslogtreecommitdiff
path: root/src/index.php
diff options
context:
space:
mode:
authorJonas Kohl2024-12-10 15:57:41 +0100
committerJonas Kohl2024-12-10 15:57:41 +0100
commit754ff1fda76b89da6793b5e553bd127cb4076571 (patch)
tree29dd1f5ffffb459fb77e8e3938ab4119423c0a86 /src/index.php
parentc79f34fcbbd558535c11b766d474b9e4c3d6682e (diff)
Add ability to add context functions
Diffstat (limited to 'src/index.php')
-rw-r--r--src/index.php5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/index.php b/src/index.php
index 4c53f0c..b7e0397 100644
--- a/src/index.php
+++ b/src/index.php
@@ -149,7 +149,7 @@ function reArrayFiles(&$file_post) {
return $file_ary;
}
-function render(string $page, array $context = []): void {
+function render(string $page, array $context = [], array $functions = []): void {
$defaultTemplate = "bootstrap-3"; // bootstrap-3 is the default for backwards compatibility
$templateDir = __ROOT__ . "/application/templates";
@@ -193,6 +193,9 @@ function render(string $page, array $context = []): void {
$twig->addFilter(new TwigFilter("base64_encode", base64_encode(...)));
$twig->addFilter(new TwigFilter("base64_decode", base64_decode(...)));
+ foreach ($functions as $fnName => $callable)
+ $twig->addFunction(new TwigFunction("ctx_$fnName", $callable));
+
echo $twig->render($page, [
"g" => [
"get" => &$_GET,