[racket] racket's template system: expand: unbound identifier

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Fri Nov 25 12:44:06 EST 2011

The lack of a space between ] and { is important. Notice that the example
in the documentation is

@in[c clients]{
   <tr><td>@(car c), @(cdr c)</td></tr>
  }

not

@in[c clients] {
   <tr><td>@(car c), @(cdr c)</td></tr>
  }

Jay

On Thu, Nov 24, 2011 at 3:06 PM, Daniel Bastos <dbastos at toledo.com> wrote:

> Good evening, gentlemen.
>
> I'm studying
>
>  http://docs.racket-lang.org/web-server/templates.html
>
> to see how web development is done in Racket. Having written a first
> hello world using templates, I'm wishing to use the @in[] call. So I
> wrote
>
> %cat templates1.rkt
> #lang racket
> (require web-server/servlet
>         web-server/servlet-env
>         web-server/templates)
>
> (define (start req)
>  (response/doit
>    (let ([friends
>           (list (cons "John" "Smith")
>                 (cons "Jack" "Smith")
>                 (cons "Joseph" "Smith"))])
>       (include-template "friends.html"))))
>
> (define (response/doit text)
>  (response/full
>    200
>    #"Okey dokey"
>    (current-seconds)
>    TEXT/HTML-MIME-TYPE
>    empty
>    (list (string->bytes/utf-8 text))))
>
> (serve/servlet start
>  #:port 80
>  #:servlet-path "/"
>  #:command-line? #t)
> %
>
> I'm getting
>
> %racket templates1.rkt
> friends.html:4:18: expand: unbound identifier in module in: c
>
>  === context ===
> standard-module-name-resolver
>
> %cat friends.html
>
>  <table>
>   @in[c friends] {
>    <tr><td>@(car c), @(cdr c)</td></tr>
>   }
>  </table>
> %
>
> Could you point towards a direction where I can always take a further
> step to dig in and find what's going wrong? (Although I'm so new at
> the technology that I might be unable to follow instructions.)
>
> Here's what I'm trying to do. I wrote templates2.rkt to test the
> include-template function.
>
> %cat templates2.rkt
> #lang racket
> (require web-server/servlet
>         web-server/servlet-env
>         web-server/templates)
>
> (define (start req)
>  (response/doit
>    (include-template "nothing.html")))
>
> [... more code omitted ...]
>
> %cat nothing.html
> hi
>
> %rlwrap racket
> Welcome to Racket v5.2.0.3.
> > (load "templates2.rkt")
> > (expand (include-template "nothing.html"))
> reference to undefined identifier: include-template
>
> I thought that by loading templates2.rkt, I could spare me from
> requiring web-server/templates.
>
> > (require web-server/templates)
> > (include-template "nothing.html")
> "hi"
>
> > (expand (include-template "nothing.html"))
> #<syntax (quote "hi")>
>
> > (syntax->datum (expand (include-template "nothing.html")))
> ''"hi"
>
> > (syntax->datum (expand (include-template "friends.html")))
> reference to undefined identifier: friends
>
>  === context ===
> /home/dbastos/plt/collects/racket/port.rkt:63:0: with-output-to-string
> /home/dbastos/plt/collects/racket/private/misc.rkt:87:7
>
> My plan was to see a little further what the code in friends.html is
> doing, but then I need to bind friends to something before I try to.
> But if I do that, the other c-unbound-identifier error will blow
> anyway and I won't see the code. I wish I could see the code before
> executing it. How do you guys do it?
> _________________________________________________
>  For list-related administrative tasks:
>  http://lists.racket-lang.org/listinfo/users
>



-- 
Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University
http://faculty.cs.byu.edu/~jay

"The glory of God is Intelligence" - D&C 93
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20111125/0bc749c1/attachment.html>

Posted on the users mailing list.