8.5 Render
(require pollen/render) | package: pollen |
Rendering is how Pollen source files get converted into output.
procedure
source-path : complete-path? template-path : (or/c #f complete-path?) = #f
A [pollen/pre] file is rendered without a template.
A [pollen/markup] or [pollen/markdown] file is rendered with a template. If no template is provided with template-path, Pollen finds one using get-template-for.
Be aware that rendering with a template uses include-template within eval. For complex pages, it can be slow the first time. Caching is used to make subsequent requests faster.
For those panicked at the use of eval, please don’t be. As the author of include-template has already advised, “If you insist on dynamicism” — and yes, I do insist — “there is always eval.”
procedure
(render-to-file source-path [ template-path output-path]) → void? source-path : complete-path? template-path : (or/c #f complete-path?) = #f output-path : (or/c #f complete-path?) = #f
procedure
(render-to-file-if-needed source-path [ template-path output-path #:force force-render?]) → void? source-path : complete-path? template-path : (or/c #f complete-path?) = #f output-path : (or/c #f complete-path?) = #f force-render? : boolean? = #f
The force-render? flag — set with the #:force keyword — is #t.
No file exists at output-path. (Thus, an easy way to force a render of a particular output-path is to delete it.)
Either source-path or template-path have changed since the last trip through render.
One or more of the project requires have changed.
If none of these conditions exist, output-path is deemed to be up to date, and the render is skipped.
procedure
(render-batch source-paths ...) → void?
source-paths : (listof pathish?)
procedure
(render-pagetree pagetree) → void?
pagetree : pagetree? (render-pagetree pagetree-source) → void? pagetree-source : pathish?
procedure
(get-template-for source-path) → (or/c #f complete-path?)
source-path : complete-path?
If the metas for source-path have a key for template, then use the value of this key.
If this key doesn’t exist, or if it points to a nonexistent file, look for a default template in the project directory with the name template.[output extension].pt. Meaning, if source-path is intro.html.pm, the output path would be intro.html, so the default template would be template.html.pt.
If this file doesn’t exist, use the fallback template as a last resort.
This function is called when a template is needed, but a template-path argument is missing (for instance, in render or render-to-file).