From 1165ba3342b4a08762e47ed67f4473ce7abb5ca3 Mon Sep 17 00:00:00 2001 From: pho4cexa Date: Fri, 2 Dec 2022 14:54:10 -0800 Subject: [PATCH] html templating using ml string w/expressions http://wiki.call-cc.org/man/5/Extensions%20to%20the%20standard#multiline-string-constant-with-embedded-expressions --- main.scm | 36 ++++++++++++------------------------ 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/main.scm b/main.scm index e03da82..b65b899 100644 --- a/main.scm +++ b/main.scm @@ -52,24 +52,23 @@ (define DESCRIPTION (or (get-environment-variable "GIT_WWW_DESCRIPTION") "my git repositories")) (define H1 (or (get-environment-variable "GIT_WWW_H1") "git.example.com")) - -(define HTML-TEMPLATE - #< -{{title}} +#{TITLE} - + -

{{h1}}

-

{{repository-name}}

-

clone url: {{clone-url}}/{{repository-name}}

+

#{H1}

+

#{*repository-name*}

+

clone url: #{CLONE-URL}/#{*repository-name*}


-{{body-contents}} +#{body} string-block @@ -104,17 +103,6 @@ string-block (define (write-file file contents) (with-output-to-file file (lambda () (display contents)))) -(define (populate-html-template body-contents) - (string-translate* - HTML-TEMPLATE - `( - ("{{title}}" . ,TITLE) - ("{{description}}" . ,DESCRIPTION) - ("{{h1}}" . ,H1) - ("{{clone-url}}" . ,CLONE-URL) - ("{{repository-name}}" . ,*repository-name*) - ("{{body-contents}}" . ,body-contents)))) - (define (in-git-directory?) (if (equal? (call-with-input-pipe "git rev-parse --is-bare-repository 2> /dev/null" read-line) "true") #t