diff options
Diffstat (limited to 'src/wrap.scm')
-rw-r--r-- | src/wrap.scm | 23 |
1 files changed, 0 insertions, 23 deletions
diff --git a/src/wrap.scm b/src/wrap.scm deleted file mode 100644 index aa077d8..0000000 --- a/src/wrap.scm +++ /dev/null | |||
@@ -1,23 +0,0 @@ | |||
1 | (declare (module (jimmy wrap))) | ||
2 | |||
3 | (import scheme (chicken base) | ||
4 | (jimmy emit) | ||
5 | (jimmy util) | ||
6 | (only (chicken io) read-string) | ||
7 | (only (chicken port) with-output-to-string) | ||
8 | (only (chicken string) string-translate* string-intersperse)) | ||
9 | |||
10 | ;; templates are strings with variables interpolated with "{{variables}}" | ||
11 | |||
12 | (define-public (wrap document template) | ||
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)))) | ||
21 | |||
22 | (define-public (wrap-with document file) | ||
23 | (wrap document (with-input-from-file file read-string))) | ||