pull/169/head
Matthew Butterick 7 years ago
parent 8495bc0309
commit fc3232303d

@ -1 +1 @@
1518738938 1518765983

@ -77,7 +77,7 @@
has/is-markup-source? has/is-markup-source?
has/is-scribble-source? has/is-scribble-source?
has/is-markdown-source?))]) has/is-markdown-source?))])
(pred so-path)) (pred so-path))
(define-values (source-path output-path) (->source+output-paths so-path)) (define-values (source-path output-path) (->source+output-paths so-path))
(render-to-file-if-needed source-path #f output-path)] (render-to-file-if-needed source-path #f output-path)]
[(pagetree-source? so-path) (render-pagenodes so-path)]) [(pagetree-source? so-path) (render-pagenodes so-path)])
@ -151,7 +151,7 @@
(define render-proc (for/first ([test (in-list tests)] (define render-proc (for/first ([test (in-list tests)]
[render-proc (in-list render-procs)] [render-proc (in-list render-procs)]
#:when (test source-path)) #:when (test source-path))
render-proc)) render-proc))
(unless render-proc (unless render-proc
(raise-argument-error 'render (format "valid rendering function for ~a" source-path) render-proc)) (raise-argument-error 'render (format "valid rendering function for ~a" source-path) render-proc))
@ -235,18 +235,18 @@
pollen/pagetree pollen/pagetree
pollen/core) pollen/core)
DIRECTORY-REQUIRE-FILES DIRECTORY-REQUIRE-FILES
(define DOC-ID (cached-doc SOURCE-PATH-STRING)) (parameterize ([current-pagetree (make-project-pagetree CPR)])
(define META-ID (cached-metas SOURCE-PATH-STRING)) (define DOC-ID (cached-doc SOURCE-PATH-STRING))
(parameterize ([current-pagetree (make-project-pagetree CPR)] (define META-ID (cached-metas SOURCE-PATH-STRING))
[current-metas META-ID])
(local-require pollen/template pollen/top) (local-require pollen/template pollen/top)
(define here (path->pagenode (or (select-from-metas 'HERE-PATH-KEY META-ID) 'unknown))) (define here (path->pagenode (or (select-from-metas 'HERE-PATH-KEY META-ID) 'unknown)))
(if (bytes? DOC-ID) ; if main export is binary, just pass it through (parameterize ([current-metas META-ID])
DOC-ID (if (bytes? DOC-ID) ; if main export is binary, just pass it through
(include-template #:command-char COMMAND-CHAR (file TEMPLATE-PATH)))))))) DOC-ID
;; set current-directory because include-template wants to work relative to source location (include-template #:command-char COMMAND-CHAR (file TEMPLATE-PATH)))))))))
(time (parameterize ([current-directory (->complete-path (dirname source-path))]) ;; set current-directory because include-template wants to work relative to source location
(render-through-eval expr-to-eval)))) (time (parameterize ([current-directory (->complete-path (dirname source-path))])
(render-through-eval expr-to-eval))))
(define (templated-source? path) (define (templated-source? path)
@ -259,7 +259,7 @@
(define (file-exists-or-has-source? p) ; p could be #f (define (file-exists-or-has-source? p) ; p could be #f
(and p (for/first ([proc (in-list (list values ->preproc-source-path ->null-source-path))] (and p (for/first ([proc (in-list (list values ->preproc-source-path ->null-source-path))]
#:when (file-exists? (proc p))) #:when (file-exists? (proc p)))
p))) p)))
(define (get-template) (define (get-template)
(define output-path (or maybe-output-path (->output-path source-path))) (define output-path (or maybe-output-path (->output-path source-path)))
@ -318,4 +318,4 @@
(parameterize ([current-namespace (make-base-namespace)] (parameterize ([current-namespace (make-base-namespace)]
[current-output-port (current-error-port)]) [current-output-port (current-error-port)])
(namespace-attach-module (namespace-anchor->namespace render-module-ns) 'pollen/setup) ; brings in params (namespace-attach-module (namespace-anchor->namespace render-module-ns) 'pollen/setup) ; brings in params
(eval expr-to-eval))) (eval expr-to-eval)))

@ -146,7 +146,7 @@ Note that if @racket[_meta-source] is a relative path or pagenode, it is treated
(select-from-metas 'nonexistent-key metas) (select-from-metas 'nonexistent-key metas)
] ]
@section{Parameters} @section[#:tag "core"]{Parameters}
@defparam[current-metas hash (or/c #f hash?) #:value #f]{Holds the @racket[metas] of the current Pollen source. In tag functions, rather than pass @racket[metas] as an argument, you can refer to @racket[(current-metas)] within the body of the function. Likewise, if your tag function calls other tag functions, they can all invoke @racket[(current-metas)] instead of passing the value around. @defparam[current-metas hash (or/c #f hash?) #:value #f]{Holds the @racket[metas] of the current Pollen source. In tag functions, rather than pass @racket[metas] as an argument, you can refer to @racket[(current-metas)] within the body of the function. Likewise, if your tag function calls other tag functions, they can all invoke @racket[(current-metas)] instead of passing the value around.

Loading…
Cancel
Save