123456789101112131415161718192021222324252627282930313233343536 |
- (define-module (templates)
- #:export (templatize
- debug-table-template))
- (use-modules (web request)
- (web response)
- (web uri))
- (define templatize
- (lambda (title body)
- "Wrap the usual stuff around the SXML of the body."
- `(html (head (title ,title)
- (link (@ (rel "stylesheet")
- (type "text/css")
- (href "/static/css/style.css"))))
- ;; Splice in the body. It could be multiple top
- ;; level expressions inside the body.
- (body ,@body))))
- (define debug-table-template
- (λ (request body)
- `((h1 "hello world!")
- (table
- (tr (th "header") (th "value"))
- ;; splice in all request headers
- ,@(map (lambda (pair)
- `(tr (td (tt ,(with-output-to-string
- (lambda () (display (car pair))))))
- (td (tt ,(with-output-to-string
- (lambda ()
- (write (cdr pair))))))))
- (request-headers request))))))
|