Neil Van Dyke
(define(write-essaymy-title)(html-template(html(head(title(%my-title)))(body(h1(%my-title))(p"Kittens claw."(br)"Puppies pee.")))))(write-essay"All About Kittens & Puppies")
<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>
(let-values(((out)(current-output-port)))(parameterize((current-output-porthtml-template-error-catching-output-port))(write-bytes#"<html><head><title>"out)(%html-template:format/content/writemy-titleout)(write-bytes#"</title></head><body><h1>"out)(%html-template:format/content/writemy-titleout)(write-bytes#"</h1><p>Kittens claw.<br>Puppies pee.</p></body></html>"out)(void)))
(html-template(html(h1"People")(p"The people are:")(table(@(border"1"))(tr(th"Name")(th"Color"))(%write(for-each(lambda(person)(html-template(tr(td(%(person-nameperson)))(td(%(person-colorperson))))))people)))(p"Fin.")))
<html><h1>People</h1><p>The people are:</p><table border="1"><tr><th>Name</th><th>Color</th></tr><tr><td>Juliette</td><td>Blue</td></tr><tr><td>Zbigniew</td><td>White</td></tr><tr><td>Irene</td><td>Red</td></tr></table><p>Fin.</p></html>
maybe-port =| #:portoutput-port-or-falsecontent-context = element| string?| bytes?| escapeelement-context = element| escapeelement = (symbol?maybe-attributescontent-context...)maybe-attributes =| (@attribute-context...+)attribute-context = attribute| escape-except-formatattribute = (symbol?attribute-value-context...+)attribute-value-context = string?| bytes?| escapeescape = escape-except-format| (%formatexpr...+)| (%expr...+)escape-except-format = (%verbatimexpr...+)| (%writeexpr...+)| (%write/portvarexpr...+)| (%voidexpr...+)
(%xexpexpr...) and (%sxmlexpr...) — expr evaluates to an SXML/xexp value, which is output as HTML in the appropriate context (e.g., content context vs. attribute value context).
(%formatexpr...) and (%expr...) — expr evaluates to some value, and this value is formatted for appropriate literal display in HTML. For example, a string value is displayed as text, an integer value is displayed as a number, a date object is displayed as a date, etc. The formatting handler is customizable by the application programmer. (Note that the meaning of % changed purposes in PLaneT version 2:0 of this package: in version 1:1, it was similar to the current %xexp, rather than being shorthand for %format.
(%verbatimexpr...) — expr evaluates to bytes, string, or a list of byteses and/or strings, which are output verbatim as bytes.
(%writeexpr...) — expr is evaluated, and any writes to current-output-port are added verbatim to the output. Note that %write and %write/port are the only template escapes that permit writing directly to a port that goes to HTML output.
(%write/portvarexpr...) — Like %write, except that writing must be to the output port var. Writing to current-output-port within %write/var will raise an error, on the assumption that it’s most likely a bug (like a missing port parameter in a display, printf, or nested html-template).
(%voidexpr...) — expr is evaluated, and any value is ignored. This is used for side-effects.
Reduce file count, using submodules.
After using submodules, move unit tests into main source file(s).
Check whether we handle script elements as CDATA rather than PCDATA, like package html-writing now does. At the same time, consider supporting “CDATA faux HTML”.
Changed the dependency on undocumented identifiers from package html-writing: html->bytes to xexp->html-bytes, and html-attribute-value-bytes->bytes to xexp->html-attribute-value-bytes.
Added Known Issue about changes to package html-writing handling of script elements.
Link to sxml-intro package.
Temporarily kludged tests that were failing on build server because DrRacket and racotest appear to use different exception message string formats.
Documentation tweaks.
Debugging build server issue.
Fixed deps.
Moving from PLaneT to new package system.
To avoid some runtime errors, a few places in template parsing that did syntax-e were changed to do syntax->list.
Element and attribute names can now contain minus and underscore characters.
Commented-out some log-debug uses.
Heavy API changes, including changing all the template escapes.
Heavy internal changes, to enable optimizations in the forthcoming web-server-xexp package.
Much more testing.
Converted to use McFly and Overeasy.
Added % as alias for %eval.
Initial release.
Copyright 2011, 2012, 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.