Rendering a standalone x-expression?

Does Pollen have any built-in procedures for rendering source X-expressions into files? In other words, is there a procedure like render / render-to-file for rendering source files, but where the input is an X-expression instead of a source path?

For context, what I’m trying to achieve is a way to render an X-expression to its own file during the rendering process of another file.

As an example, let’s say I have Pollen markup file page1.html.pm:

#lang pollen

Some content.

◊separate-page{"Content on another page"}

Some more content

I’m desiring a result where during the rendering process of page1.html, when the function separate-page gets evaluated, a different page gets rendered using whatever was input to separate-page.

In other words, separate-page returns nothing, but renders its input into a separate output. If we pretend that such a rendering function exists, it might look like:

(define (separate-page . content)
  (render-x-expression `(html (body (div ,@content))))
  `(span ""))

Ideally this function would let me pass in a template path and output path as well, just like the other pollen/render functions available.


For additional context: I’m pairing my site with a Django webserver, and on some pages, there is content that I would like to be served only upon request. I’m trying to make it so that all of the page content, even that which is served by the server, is contained within the Pollen source file.

Is there a reason you don’t want to write the X-expression to a file with make-temporary-file and then proceed normally?

No, I was just curious if there was a way to cut out the middleman. If writing to a file first is the only way (without hacking at Pollen internals), I can definitely work with that.