[racket] web-server/templates: "require: not at module level or top level"

From: Greg Hendershott (greghendershott at gmail.com)
Date: Tue Nov 26 00:17:07 EST 2013

Why doesn't `require` work in a file provided to `include-template`
from web-server/templates?

I dug into the source to see how far I could figure this out on my
own. I see that `include-template` is a thin wrapper around
`include/text` from scribble/text. I see in syntax-utils.rkt that
`include/text` is using `include-at/relative-to/reader` with a
Scribble syntax reader. But at that point it gets over my head.

Motivating example: In their HTML template someone would like to
`require` a module to do some fancy formatting of a template variable.
Let's say they get a date, and want to `(require racket/date)` for
`date->string` and its various options.  Or, they want to do whatever
else, and it requires (ha) some module.

Posted on the users mailing list.