From cf6af6def1cac3fc6cd044c82282208b7073eb64 Mon Sep 17 00:00:00 2001 From: Brian Picciano Date: Fri, 1 Nov 2024 13:00:18 +0100 Subject: Implement gemtext HTTP middleware --- example/tpl/render_gemtext_with_templates.html | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 example/tpl/render_gemtext_with_templates.html (limited to 'example/tpl/render_gemtext_with_templates.html') diff --git a/example/tpl/render_gemtext_with_templates.html b/example/tpl/render_gemtext_with_templates.html new file mode 100644 index 0000000..72e35a4 --- /dev/null +++ b/example/tpl/render_gemtext_with_templates.html @@ -0,0 +1,15 @@ +{{ $pathSplit := splitList "/" .Req.URL.Path }} +{{ $base := last $pathSplit | default "index.gmi" }} +{{ $filePath := append (initial $pathSplit) $base | join "/" | printf "static%s" }} +{{ if not (fileExists $filePath) }}{{ httpError 404 }}{{ end }} +{{ $gemtextRes := gemtext (include $filePath) }} + + + + {{ $gemtextRes.Title | default "Example Gemtext File" }} + + + + {{ $gemtextRes.Body }} + + -- cgit v1.2.3