improve handling of binary output

pull/29/head
Matthew Butterick 10 years ago
parent 2e9109ae97
commit d3b3cff797

@ -0,0 +1,23 @@
#lang racket/base
(require scribble/text
(for-syntax racket/base
racket/list
syntax/parse)
racket/port)
;; Adaptation of function in web-server/templates library
;; to check for binary result and pass it through.
;; Actually patches underlying bug in `output`.
(define-syntax (include-template stx)
(syntax-parse stx
[(_ (~optional (~seq #:command-char command-char:expr)) p:expr)
(quasisyntax/loc stx
(let ([result (include/text #,@(if (attribute command-char)
(list #'#:command-char #'command-char)
empty)
p)])
(if (bytes? result)
(with-output-to-bytes (λ () (write-bytes result)))
(with-output-to-string (λ () (output result))))))]))
(provide include-template)

@ -164,7 +164,7 @@
(define expr-to-eval
`(begin
(require (for-syntax racket/base))
(require web-server/templates pollen/cache pollen/debug)
(require pollen/include-template pollen/cache pollen/debug)
,(require-directory-require-files source-path)
(let ([doc (cached-require ,(path->string source-path) ',world:main-pollen-export)]
[metas (cached-require ,(path->string source-path) ',world:meta-pollen-export)])
@ -232,8 +232,7 @@
(eval `(require ,module-name) cache-ns)
(current-eval-namespace-cache (cons cache-ns (cons module-name cached-modules)))))
(define initial-modules-to-cache '(web-server/templates
xml
(define initial-modules-to-cache '(xml
racket/port
racket/file
racket/rerequire
@ -245,6 +244,7 @@
pollen/debug
pollen/decode
pollen/file
pollen/include-template
pollen/main
pollen/reader-base
pollen/pagetree

Loading…
Cancel
Save