about summary refs log tree commit diff stats
path: root/src/wrap.scm
diff options
context:
space:
mode:
authorCase Duckworth2024-05-26 22:49:44 -0500
committerCase Duckworth2024-05-26 22:52:25 -0500
commit815e669310f5e73d13cc121bd7f6cdaec5b6ec0d (patch)
tree1d3ab042bb6ffc2302a0a03b61147e5b4a649960 /src/wrap.scm
parentScheme bit! (diff)
downloadjimmy-815e669310f5e73d13cc121bd7f6cdaec5b6ec0d.tar.gz
jimmy-815e669310f5e73d13cc121bd7f6cdaec5b6ec0d.zip
Updates!
I totally forgot to actually commit things for a while, so uh

Updates!!!
Diffstat (limited to 'src/wrap.scm')
-rw-r--r--src/wrap.scm20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/wrap.scm b/src/wrap.scm index 3537dea..0ed8868 100644 --- a/src/wrap.scm +++ b/src/wrap.scm
@@ -1,13 +1,23 @@
1(declare (module (jimmy wrap))) 1(declare (module (jimmy wrap)))
2 2
3(import scheme (chicken base) 3(import scheme (chicken base)
4 (jimmy emit)
4 (jimmy util) 5 (jimmy util)
5 (chicken format)) 6 (only (chicken io) read-string)
7 (only (chicken port) with-output-to-string)
8 (only (chicken string) string-translate*))
6 9
7;;; open question: how to do templating? 10;; templates are strings with variables interpolated with "{{variables}}"
8 11
9(define-public (wrap document template) 12(define-public (wrap document template)
10 #f) 13 (let* ((meta (map (lambda (el)
14 (cons (string-append "{{" (car el) "}}")
15 (string-intersperse (cdr el) " ")))
16 (alist-walk document 'meta)))
17 (body (cons "{{body}}"
18 (with-output-to-string
19 (lambda () (emit document))))))
20 (string-translate* template (cons body meta))))
11 21
12(define (meta-get key document) 22(define-public (wrap-with document file)
13 (alist-walk document 'meta key)) 23 (wrap document (with-input-from-file file read-string)))