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

From: Joe Gibbs Politz (joe at cs.brown.edu)
Date: Tue Nov 26 09:45:10 EST 2013

+1 for having hit this minor bump (probably for the same use case as
Greg: Frog templates).

I used dynamic-require, after having tried plain require and getting
this error message.


On Tue, Nov 26, 2013 at 12:17 AM, Greg Hendershott
<greghendershott at gmail.com> wrote:
> 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.
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users

Posted on the users mailing list.