greghendershott / frog

Frog is a static blog generator implemented in Racket, targeting Bootstrap and able to use Pygments.
916 stars 96 forks source link

Requiring in the template is cumbersome #235

Closed sorawee closed 5 years ago

sorawee commented 5 years ago

Say, I want to call (date->string date-struct). However, date->string is in racket/date, but we can't require it either because template rendering doesn't seem to allow require.

A way that I am currently using is:

@(define date->string (dynamic-require 'racket/date 'date->string))

which is obviously not ideal.

It would be nice to be able to supply user-custom variables for template rendering.

greghendershott commented 5 years ago

One of the items under "General Template Tips" in the docs is this:

5.5.2 Use local-require in templates

If you need to require a Racket module in your template, you must use local-require. Plain require won’t work because the template is not evaluated at a module level or top level.

Does that help?

sorawee commented 5 years ago

This addresses my issue. Thanks :)