On Tuesday, February 19, 2019 at 5:06:32 PM UTC-5, Matthew Butterick wrote:
>
>
>
> On Feb 19, 2019, at 1:28 PM, Brian Adkins <[email protected] 
> <javascript:>> wrote:
>
> Oops - I spoke too soon. It appears the lexical context is unavailable to 
> the template when include-template is used in this manner. 
>
>
> Ah right, one has to inject STR into the same lexical context, like so:
>
>
> #lang racket
> (require web-server/templates)
>
> (define-syntax (include-template/named stx)
>   (syntax-case stx ()
>     [(_ NAME)
>      (with-syntax ([STR (datum->syntax #'NAME (string-append 
> "../views/authentication/" (symbol->string (syntax-e #'NAME)) ".html"))]) 
>        #'(include-template STR))]))
>
> (define (login request)
>   (include-template/named login))
>


Awesome - that did the trick. I'm confused as to why it helped to inject 
STR into the lexical context - it ends up being just a string, and it was 
working fine with respect to loading the template. I would think the fix 
would be to inject include-template into the lexical context. I suppose it 
must have something to do with how the include-template macro is dealing 
with that argument. 

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to