[plt-scheme] Templates in the PLT Web Server

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Thu Nov 20 11:33:17 EST 2008

Almost all Web application frameworks have a templating system to
allow the dynamic portion of a site to modify some semi-static content
before displaying it. These frameworks are primarily useful because
they allow the contributions of non-programmers to be more easily
integrated into an application and remove a barrier to using
traditional HTML design tools, like Amaya and Dreamweaver.

The PLT Web Server now provides a templating system of its own. It
uses the syntax of Scribble to provide access to all features of PLT
Scheme to template authors. Furthermore, it requires zero run-time
parsing of templates—the templates your servlet uses are loaded and
compiled when your servlet is compiled.

The documentation [1] has all the details about using templates in
your applications. But here's a short example:


@in[c clients]{
 <tr><td>@(car c), @(cdr c)</td></tr>


(let ([clients (list (cons "Young" "Brigham")
                        (cons "Smith" "Joseph"))])
 (include-template "template.html"))

Evaluates to:

 <tr><td>Young, Brigham</td></tr>
 <tr><td>Smith, Joseph</td></tr>

1. http://docs.plt-scheme.org/web-server/templates.html

Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University

"The glory of God is Intelligence" - D&C 93

Posted on the users mailing list.