|
|
@ -178,16 +178,17 @@
|
|
|
|
(define expr-to-eval
|
|
|
|
(define expr-to-eval
|
|
|
|
`(begin
|
|
|
|
`(begin
|
|
|
|
(require (for-syntax racket/base))
|
|
|
|
(require (for-syntax racket/base))
|
|
|
|
(require pollen/include-template pollen/cache pollen/debug)
|
|
|
|
(require pollen/include-template pollen/cache pollen/debug pollen/pagetree)
|
|
|
|
,(require-directory-require-files source-path)
|
|
|
|
,(require-directory-require-files source-path)
|
|
|
|
(let ([,(world:current-main-export) (cached-require ,(path->string source-path) ',(world:current-main-export))]
|
|
|
|
(parameterize ([current-pagetree (make-project-pagetree ,(world:current-project-root))])
|
|
|
|
[,(world:current-meta-export) (cached-require ,(path->string source-path) ',(world:current-meta-export))])
|
|
|
|
(let ([,(world:current-main-export) (cached-require ,(path->string source-path) ',(world:current-main-export))]
|
|
|
|
(local-require pollen/pagetree pollen/template pollen/top)
|
|
|
|
[,(world:current-meta-export) (cached-require ,(path->string source-path) ',(world:current-meta-export))])
|
|
|
|
(define here (metas->here ,(world:current-meta-export)))
|
|
|
|
(local-require pollen/template pollen/top)
|
|
|
|
(cond
|
|
|
|
(define here (metas->here ,(world:current-meta-export)))
|
|
|
|
[(bytes? ,(world:current-main-export)) ,(world:current-main-export)] ; if main export is binary, just pass it through
|
|
|
|
(cond
|
|
|
|
[else
|
|
|
|
[(bytes? ,(world:current-main-export)) ,(world:current-main-export)] ; if main export is binary, just pass it through
|
|
|
|
(include-template #:command-char ,(world:current-command-char) (file ,(->string (find-relative-path source-dir template-path))))]))))
|
|
|
|
[else
|
|
|
|
|
|
|
|
(include-template #:command-char ,(world:current-command-char) (file ,(->string (find-relative-path source-dir template-path))))])))))
|
|
|
|
(time (parameterize ([current-directory (->complete-path source-dir)]) ; because include-template wants to work relative to source location
|
|
|
|
(time (parameterize ([current-directory (->complete-path source-dir)]) ; because include-template wants to work relative to source location
|
|
|
|
(render-through-eval expr-to-eval))))
|
|
|
|
(render-through-eval expr-to-eval))))
|
|
|
|
|
|
|
|
|
|
|
@ -208,9 +209,9 @@
|
|
|
|
(list
|
|
|
|
(list
|
|
|
|
;; this op touches the cache so set up current-directory correctly
|
|
|
|
;; this op touches the cache so set up current-directory correctly
|
|
|
|
(parameterize ([current-directory (world:current-project-root)])
|
|
|
|
(parameterize ([current-directory (world:current-project-root)])
|
|
|
|
(let ([source-metas (cached-require source-path (world:current-meta-export))])
|
|
|
|
(let ([source-metas (cached-require source-path (world:current-meta-export))])
|
|
|
|
(and (hash-has-key? source-metas (->symbol (world:current-template-meta-key)))
|
|
|
|
(and (hash-has-key? source-metas (->symbol (world:current-template-meta-key)))
|
|
|
|
(build-path source-dir (select-from-metas (->string (world:current-template-meta-key)) source-metas))))) ; path based on metas
|
|
|
|
(build-path source-dir (select-from-metas (->string (world:current-template-meta-key)) source-metas))))) ; path based on metas
|
|
|
|
(and (filename-extension output-path) (build-path (world:current-project-root)
|
|
|
|
(and (filename-extension output-path) (build-path (world:current-project-root)
|
|
|
|
(add-ext (world:current-default-template-prefix) (get-ext output-path))))))) ; path to default template
|
|
|
|
(add-ext (world:current-default-template-prefix) (get-ext output-path))))))) ; path to default template
|
|
|
|
(and (filename-extension output-path) (build-path (world:current-server-extras-path) (add-ext (world:current-fallback-template-prefix) (get-ext output-path)))))))) ; fallback template
|
|
|
|
(and (filename-extension output-path) (build-path (world:current-server-extras-path) (add-ext (world:current-fallback-template-prefix) (get-ext output-path)))))))) ; fallback template
|
|
|
@ -223,43 +224,8 @@
|
|
|
|
(> (length (dynamic-rerequire source-path)) 0)))
|
|
|
|
(> (length (dynamic-rerequire source-path)) 0)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; set up namespace for module caching
|
|
|
|
|
|
|
|
(define-caching-ns caching-module-ns)
|
|
|
|
|
|
|
|
(define cached-module-names '(xml
|
|
|
|
|
|
|
|
racket/bool
|
|
|
|
|
|
|
|
racket/class
|
|
|
|
|
|
|
|
racket/contract
|
|
|
|
|
|
|
|
racket/draw
|
|
|
|
|
|
|
|
racket/file
|
|
|
|
|
|
|
|
racket/format
|
|
|
|
|
|
|
|
racket/function
|
|
|
|
|
|
|
|
racket/port
|
|
|
|
|
|
|
|
racket/list
|
|
|
|
|
|
|
|
racket/match
|
|
|
|
|
|
|
|
racket/string
|
|
|
|
|
|
|
|
racket/syntax
|
|
|
|
|
|
|
|
pollen/cache
|
|
|
|
|
|
|
|
pollen/debug
|
|
|
|
|
|
|
|
pollen/decode
|
|
|
|
|
|
|
|
pollen/file
|
|
|
|
|
|
|
|
pollen/include-template
|
|
|
|
|
|
|
|
pollen/main
|
|
|
|
|
|
|
|
pollen/reader-base
|
|
|
|
|
|
|
|
pollen/pagetree
|
|
|
|
|
|
|
|
pollen/rerequire
|
|
|
|
|
|
|
|
pollen/tag
|
|
|
|
|
|
|
|
pollen/template
|
|
|
|
|
|
|
|
pollen/world
|
|
|
|
|
|
|
|
pollen/project
|
|
|
|
|
|
|
|
sugar
|
|
|
|
|
|
|
|
txexpr))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(apply load-in-namespace caching-module-ns cached-module-names)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define/contract (render-through-eval expr-to-eval)
|
|
|
|
(define/contract (render-through-eval expr-to-eval)
|
|
|
|
(list? . -> . (or/c string? bytes?))
|
|
|
|
(list? . -> . (or/c string? bytes?))
|
|
|
|
(parameterize ([current-namespace (make-base-namespace)]
|
|
|
|
(parameterize ([current-namespace (make-base-namespace)]
|
|
|
|
[current-output-port (current-error-port)]
|
|
|
|
[current-output-port (current-error-port)])
|
|
|
|
[current-pagetree (make-project-pagetree (world:current-project-root))])
|
|
|
|
(eval expr-to-eval)))
|
|
|
|
(apply copy-from-namespace caching-module-ns (current-namespace) cached-module-names)
|
|
|
|
|
|
|
|
(eval expr-to-eval (current-namespace))))
|
|
|
|
|