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
  
  })


On Monday, March 18, 2019 at 11:56:25 AM UTC-4, Philip McGrath wrote:
>
> 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 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 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 .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


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 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 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+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[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 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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[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 Monday, March 18, 2019 at 4:41:41 PM UTC+1, Jérôme Martin wrote:
>
> (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 would one translate the following Ruby template into a Racket web 
>> template (including multiple lines for the if and else clauses) ?
>>
>> <% if true %>
>>   
>>  This will be displayed if true
>>   
>> <% else %>
>>   
>> This will be displayed if false
>>   
>> <% end %>
>>
>> I've read a fair amount of doc and was unable to find a simple example 
>> like the above. I think this is a pretty common need, so an example in the 
>> docs would be awesome. The "for" example with the recommendation to use 
>> "in" was helpful.
>>
>> Thanks,
>> Brian
>>
>

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[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 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 would one translate the following Ruby template into a Racket web 
>> template (including multiple lines for the if and else clauses) ?
>>
>> <% if true %>
>>   
>>  This will be displayed if true
>>   
>> <% else %>
>>   
>> This will be displayed if false
>>   
>> <% end %>
>>
>> I've read a fair amount of doc and was unable to find a simple example 
>> like the above. I think this is a pretty common need, so an example in the 
>> docs would be awesome. The "for" example with the recommendation to use 
>> "in" was helpful.
>>
>> Thanks,
>> Brian
>>
>

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[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 would one translate the following Ruby template into a Racket web 
> template (including multiple lines for the if and else clauses) ?
>
> <% if true %>
>   
>  This will be displayed if true
>   
> <% else %>
>   
> This will be displayed if false
>   
> <% end %>
>
> I've read a fair amount of doc and was unable to find a simple example 
> like the above. I think this is a pretty common need, so an example in the 
> docs would be awesome. The "for" example with the recommendation to use 
> "in" was helpful.
>
> Thanks,
> Brian
>

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.