diff options
Diffstat (limited to 'example/tpl')
-rw-r--r-- | example/tpl/render_gemtext.html | 9 | ||||
-rw-r--r-- | example/tpl/render_gemtext_link.html | 5 | ||||
-rw-r--r-- | example/tpl/render_gemtext_with_templates.html | 15 |
3 files changed, 22 insertions, 7 deletions
diff --git a/example/tpl/render_gemtext.html b/example/tpl/render_gemtext.html index 72e35a4..82d3c02 100644 --- a/example/tpl/render_gemtext.html +++ b/example/tpl/render_gemtext.html @@ -1,15 +1,10 @@ -{{ $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) }} <!DOCTYPE html> <html> <head> - <title>{{ $gemtextRes.Title | default "Example Gemtext File" }}</title> + <title>{{ .Title | default "Example Gemtext File" }}</title> <link rel="stylesheet" type="text/css" href="/bamboo.css" /> </head> <body> - {{ $gemtextRes.Body }} + {{ .Body }} </body> </html> diff --git a/example/tpl/render_gemtext_link.html b/example/tpl/render_gemtext_link.html new file mode 100644 index 0000000..b0d1251 --- /dev/null +++ b/example/tpl/render_gemtext_link.html @@ -0,0 +1,5 @@ +{{- $url := .URL }} +{{- if (hasPrefix "gemini://" $url) }} + {{- $url = printf "https://gemini.tildeverse.org/?%s" $url }} +{{- end }} +<p><a href="{{ $url }}">{{ .Label }}</a></p> 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) }} +<!DOCTYPE html> +<html> + <head> + <title>{{ $gemtextRes.Title | default "Example Gemtext File" }}</title> + <link rel="stylesheet" type="text/css" href="/bamboo.css" /> + </head> + <body> + {{ $gemtextRes.Body }} + </body> +</html> |