summaryrefslogtreecommitdiff
path: root/skin
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2022-07-07 20:31:22 +0300
committerEvgeny Zinoviev <me@ch1p.io>2022-07-07 20:31:22 +0300
commit6c081f3aff64689ed3b77bfeec1d2e0005fe5286 (patch)
treeceaeb1c9b235a7f701039d11da145bd18ae98be3 /skin
initial
Diffstat (limited to 'skin')
-rw-r--r--skin/base.skin.php15
-rw-r--r--skin/main.skin.php29
2 files changed, 44 insertions, 0 deletions
diff --git a/skin/base.skin.php b/skin/base.skin.php
new file mode 100644
index 0000000..d5e02e2
--- /dev/null
+++ b/skin/base.skin.php
@@ -0,0 +1,15 @@
+<?php
+
+namespace skin\base;
+
+function layout($ctx, $title, $unsafe_body) {
+return <<<HTML
+<!doctype html>
+<html lang="en">
+ <body>
+ <title>{$title}</title>
+ </body>
+ <body>{$unsafe_body}</body>
+</html>
+HTML;
+}
diff --git a/skin/main.skin.php b/skin/main.skin.php
new file mode 100644
index 0000000..f44f739
--- /dev/null
+++ b/skin/main.skin.php
@@ -0,0 +1,29 @@
+<?php
+
+namespace skin\main;
+
+function index($ctx, $name, $show_cities, $cities) {
+return <<<HTML
+ Hello, {$name}!<br/>
+
+ {$ctx->if_true($show_cities, 'line of truth<br/>')}
+ {$ctx->if_not(false, $ctx->renderIfFalse, '<b>safe<b>', '<b>unsafe<b>')}
+
+ <ul>
+ {$ctx->for_each($cities, fn($city, $i) => $ctx->renderIndexCityItem($city, $i+1))}
+ </ul>
+HTML;
+}
+
+function renderIndexCityItem($ctx, $city, $index) {
+return <<<HTML
+ <li>{$index} {$city}</li>
+HTML;
+}
+
+function renderIfFalse($ctx, $str, $unsafe_str) {
+return <<<HTML
+safe: $str<br/>
+unsafe: $unsafe_str
+HTML;
+} \ No newline at end of file