The lack of a space between ] and { is important. Notice that the example in the documentation is<div><br></div><div><div>@in[c clients]{</div><div> <tr><td>@(car c), @(cdr c)</td></tr></div><div>
}</div><div><br></div><div>not</div><div><br></div><div><div>@in[c clients] {</div><div> <tr><td>@(car c), @(cdr c)</td></tr></div><div> }</div></div><div><br></div>Jay</div><div><br><div class="gmail_quote">
On Thu, Nov 24, 2011 at 3:06 PM, Daniel Bastos <span dir="ltr"><<a href="mailto:dbastos@toledo.com">dbastos@toledo.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Good evening, gentlemen.<br>
<br>
I'm studying<br>
<br>
<a href="http://docs.racket-lang.org/web-server/templates.html" target="_blank">http://docs.racket-lang.org/web-server/templates.html</a><br>
<br>
to see how web development is done in Racket. Having written a first<br>
hello world using templates, I'm wishing to use the @in[] call. So I<br>
wrote<br>
<br>
%cat templates1.rkt<br>
#lang racket<br>
(require web-server/servlet<br>
web-server/servlet-env<br>
web-server/templates)<br>
<br>
(define (start req)<br>
(response/doit<br>
(let ([friends<br>
(list (cons "John" "Smith")<br>
(cons "Jack" "Smith")<br>
(cons "Joseph" "Smith"))])<br>
(include-template "friends.html"))))<br>
<br>
(define (response/doit text)<br>
(response/full<br>
200<br>
#"Okey dokey"<br>
(current-seconds)<br>
TEXT/HTML-MIME-TYPE<br>
empty<br>
(list (string->bytes/utf-8 text))))<br>
<br>
(serve/servlet start<br>
#:port 80<br>
#:servlet-path "/"<br>
#:command-line? #t)<br>
%<br>
<br>
I'm getting<br>
<br>
%racket templates1.rkt<br>
friends.html:4:18: expand: unbound identifier in module in: c<br>
<br>
=== context ===<br>
standard-module-name-resolver<br>
<br>
%cat friends.html<br>
<br>
<table><br>
@in[c friends] {<br>
<tr><td>@(car c), @(cdr c)</td></tr><br>
}<br>
</table><br>
%<br>
<br>
Could you point towards a direction where I can always take a further<br>
step to dig in and find what's going wrong? (Although I'm so new at<br>
the technology that I might be unable to follow instructions.)<br>
<br>
Here's what I'm trying to do. I wrote templates2.rkt to test the<br>
include-template function.<br>
<br>
%cat templates2.rkt<br>
#lang racket<br>
(require web-server/servlet<br>
web-server/servlet-env<br>
web-server/templates)<br>
<br>
(define (start req)<br>
(response/doit<br>
(include-template "nothing.html")))<br>
<br>
[... more code omitted ...]<br>
<br>
%cat nothing.html<br>
hi<br>
<br>
%rlwrap racket<br>
Welcome to Racket v5.2.0.3.<br>
> (load "templates2.rkt")<br>
> (expand (include-template "nothing.html"))<br>
reference to undefined identifier: include-template<br>
<br>
I thought that by loading templates2.rkt, I could spare me from<br>
requiring web-server/templates.<br>
<br>
> (require web-server/templates)<br>
> (include-template "nothing.html")<br>
"hi"<br>
<br>
> (expand (include-template "nothing.html"))<br>
#<syntax (quote "hi")><br>
<br>
> (syntax->datum (expand (include-template "nothing.html")))<br>
''"hi"<br>
<br>
> (syntax->datum (expand (include-template "friends.html")))<br>
reference to undefined identifier: friends<br>
<br>
=== context ===<br>
/home/dbastos/plt/collects/racket/port.rkt:63:0: with-output-to-string<br>
/home/dbastos/plt/collects/racket/private/misc.rkt:87:7<br>
<br>
My plan was to see a little further what the code in friends.html is<br>
doing, but then I need to bind friends to something before I try to.<br>
But if I do that, the other c-unbound-identifier error will blow<br>
anyway and I won't see the code. I wish I could see the code before<br>
executing it. How do you guys do it?<br>
_________________________________________________<br>
For list-related administrative tasks:<br>
<a href="http://lists.racket-lang.org/listinfo/users" target="_blank">http://lists.racket-lang.org/listinfo/users</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>Jay McCarthy <<a href="mailto:jay@cs.byu.edu" target="_blank">jay@cs.byu.edu</a>><br>Assistant Professor / Brigham Young University<br><a href="http://faculty.cs.byu.edu/~jay" target="_blank">http://faculty.cs.byu.edu/~jay</a><br>
<br>"The glory of God is Intelligence" - D&C 93<br>
</div>