multi line scribble text body in web-server template

30 views
Skip to first unread message

krs...@gmail.com

unread,
Nov 1, 2020, 11:55:00 AM11/1/20
to Racket Users

Hi!,

I am confused why this just displays the last line?:

@when[#t]{
<h1>first</h1>
<h1>second</h1>
}

I including html only when a user is logged in, and my issue can be distilled to the above template syntax.

Happy to elaborate, thank!

--
Paul

Ben Greenman

unread,
Nov 1, 2020, 12:22:32 PM11/1/20
to krs...@gmail.com, Racket Users
Thats the nor

On 11/1/20, krs...@gmail.com <krs...@gmail.com> wrote:
>
> Hi!,
>
> I am using web-server/templates
> <https://docs.racket-lang.org/web-server/templates.html?q=web%20server>.
> I am confused why this just displays the last line?:
>
> @when[#t]{
> <h1>first</h1>
> <h1>second</h1>
> }

That's normal "when" behavior

```
Welcome to Racket v7.8.0.5 [cs].
> (when #t "first" "second")
"second"
```

One fix is to put a list of text in the `when` body. He's how I'd write it:

```
#lang at-exp racket

@(define (when-logged-in . pc*)
(when #t
pc*))

@when-logged-in{
```

Jay McCarthy

unread,
Nov 1, 2020, 12:41:22 PM11/1/20
to Ben Greenman, krs...@gmail.com, Racket Users
This section of the documentation discusses a similar issue that may help you:


--
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 racket-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/CAFUu9R5y6%2B6dCeEYEYRTmKVcHr%3DgZQ9UbztXyy82hKD6AxjPNA%40mail.gmail.com.

krs...@gmail.com

unread,
Nov 1, 2020, 1:07:51 PM11/1/20
to Racket Users
This is so cool, thank you both!

So my quick fix is:
@when[#t]{
@list{
line1
line2
line3
}
}

And I have been using that Iteration Gotchas code, but I was using it blindly.
Now I can reason thru it better.  
Reply all
Reply to author
Forward
0 new messages