Re: [racket-users] Re: Simple conditional in web template

2019-03-18 Thread Brian Adkins
Thanks, once I removed the initial , it worked fine. Way too much extra punctuation for my taste, but it's a good workaround for now until I can come up with something more concise. @(if #t @`{ This will be displayed if true } @`{ This will be displayed if false })

Re: [racket-users] Re: Simple conditional in web template

2019-03-18 Thread Philip McGrath
I don't use `include-template` (I've come to love x-expressions), but I believe this would work: @,(if #true @`{ This will be displayed if true } @`{ This will be displayed if false }) -Philip On Mon, Mar 18, 2019 at 11:48 AM Jérôme Martin wrote: > > On Monday, March 18, 2019

[racket-users] Re: Simple conditional in web template

2019-03-18 Thread Jérôme Martin
On Monday, March 18, 2019 at 4:45:19 PM UTC+1, Brian Adkins wrote: > > Yes, using code would certainly make some things easier, but for the > moment, I'm looking for a template solution. > Oh sorry, I didn't quite catch that! I never used templates, so I don't know. -- You received this

[racket-users] Re: Simple conditional in web template

2019-03-18 Thread Jérôme Martin
Some precisions: You ever need to have a "p" procedure to generate the paragraph (for example from html-lib) or quote it in my example, otherwise it won't work. The trick is to use a quasiquotation (backtick) to render your HTML template, and unquote (comma) to put logic in the template. On

[racket-users] Re: Simple conditional in web template

2019-03-18 Thread Brian Adkins
Yes, using code would certainly make some things easier, but for the moment, I'm looking for a template solution. On Monday, March 18, 2019 at 11:41:41 AM UTC-4, Jérôme Martin wrote: > > (define (my-server-response show-cat?) > (response/xexpr > `(div ([class "my-content"]) > ,(if

[racket-users] Re: Simple conditional in web template

2019-03-18 Thread Jérôme Martin
(define (my-server-response show-cat?) (response/xexpr `(div ([class "my-content"]) ,(if show-cat? (p "Welcome to my blog about cats!") (p "This blog is definitely not about cats.") On Monday, March 18, 2019 at 4:26:16 PM UTC+1, Brian Adkins wrote: > > How