rws-html-template:   Racket Web Server html-template Support
1 Introduction
2 Interface
response/  html-template
3 Known Issues
4 History
5 Legal
2:0

rws-html-template: Racket Web Server html-template Support

Neil Van Dyke

1 Introduction

This rws-html-template package helps use the SXML-based html-template package with the Racket Web Server. Specifically, it provides a response/html-template syntax that can be used like html-template, but producing a Racket Web Server response value.
As a quick example, here’s the next hot dotcom:
#lang web-server/insta
(require rws-html-template)
 
(define (start req)
  (response/html-template
   (html (header (title "advice-pin-oogly-book-r.com"))
         (body (h1 "Today's Advice")
               (p "Don't run with "
                  (% (random-list-element '("scissors"
                                            "cheese graters"
                                            "toilet plungers"
                                            "trays of lasagna"
                                            "wolves"
                                            "the bulls"
                                            "cats")))
                  ".")
               (p "Like us on Facebook for a chance to win $"
                  (% (+ 100 (random 901)))
                  ".")))))
 
(define (random-list-element lst)
  (list-ref lst (random (length lst))))

2 Interface

syntax

(response/html-template maybe-code
                        maybe-message
                        maybe-seconds
                        maybe-mime-type
                        maybe-headers
                        maybe-cookies
                        maybe-preamble
                        content ...)
 
maybe-code = 
  | #:code      number?
     
maybe-message = 
  | #:message   bytes?
     
maybe-seconds = 
  | #:seconds   number?
     
maybe-mime-type = 
  | #:mime-type (or/c #f bytes?)
     
maybe-headers = 
  | #:headers   (listof header?)
     
maybe-cookies = 
  | #:cookies   (listof cookie?)
     
maybe-preamble = 
  | #:preamble  (or/c bytes? string?)
Like html-template, but producing a Racket Web Server response value.

3 Known Issues

4 History

5 Legal

Copyright 2013, 2016 Neil Van Dyke. This program is Free Software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License,or (at your option) any later version. This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose. See http://www.gnu.org/licenses/ for details. For other licenses and consulting, please contact the author.