html-template: HTML Writing Template Language based on SXML/xexp in Racket
License: LGPL 3 Web: http://www.neilvandyke.org/racket-html-template/
(require (planet neil/html-template:1:=0)) |
1 Introduction
Note: This package is in a state of active development, and some interface changes, perhaps not backward-compatible, are expected. Documentation is gravely lacking.
The html-template package implements an HTML-writing template language based on SXML/xexp. Compared to doing comparable work using the html-writing package, html-template offers improved compile-time error-checking and improved run-time efficiency.
!!! For example:
(define (write-essay my-title) (html-template (html (head (title (%eval my-title))) (body (h1 (%eval my-title)) (p "Kittens claw." (br) "Puppies pee."))))) (write-essay "All About Kittens & Puppies")
produces the output:
<html><head><title>All About Kittens & |
Puppies</title></head><body><h1>All About |
Kittens & Puppies</h1><p>Kittens |
claw.<br />Puppies pee.</p></body></html> |
!!! Expanding the html-template macro in this case results in something like:
(define (write-essay my-title) (display "<html><head><title>") (write-html my-title) (display "</title></head><body><h1>") (write-html my-title) (display "</h1><p>Kittens claw.<br />Puppies pee.</p></body></html>"))
Note that much of the computation for HTML formatting is done at compile time rather than at run time.
!!!
2 Interface
!!!
(html-template xexp ...) → any/c |
xexp : any/c |
... : any/c |
!!!
(html-template/port port xexp ...) → any/c |
port : any/c |
xexp : any/c |
... : any/c |
Behaves as html-template, with the addition that the current-output-port parameter set to port by parameterize for the duration, including for run-time evaluations as a result of %eval/effects-only and %eval forms.
(html-template-to-string xexp ...) → any/c |
xexp : any/c |
... : any/c |
!!!
3 Debugging
(html-template-debug-expand xexp ...) → any/c |
xexp : any/c |
... : any/c |
!!!
4 History
Version 0.1 —
2011-08-21 – PLaneT (1 0)
5 Legal
Copyright (c) 2011 Neil Van Dyke. This program is Free Software; 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 (LGPL 3), 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.
Standard Documentation Format Note: The API signatures in this documentation are likely incorrect in some regards, such as indicating type any/c for things that are not, and not indicating when arguments are optional. This is due to a transitioning from the Texinfo documentation format to Scribble, which the author intends to finish someday.