Templates

svn: r12500
This commit is contained in:
Jay McCarthy 2008-11-18 22:03:44 +00:00
parent cb68faa140
commit a01728e63a
3 changed files with 17 additions and 6 deletions

View File

@ -3,7 +3,7 @@
<body>
<table>
@in[c @clients]{
@t{
@list{
<tr>
<td>@(client-surname c), @(client-firstname c)</td>
<td><a href="mailto:@(client-email c)">@(client-email c)</a></td>

View File

@ -1,5 +1,5 @@
@(if (@monkeys . > . @monkey-limit)
@t{<p>There are too many monkeys!</p>}
@list{<p>There are too many monkeys!</p>}
@(if (@monkeys . < . @monkey-minimum)
@t{<p>There aren't enough monkeys!</p>}
@t{<p>There are just enough monkeys!</p>}))
@list{<p>There aren't enough monkeys!</p>}
@list{<p>There are just enough monkeys!</p>}))

View File

@ -1,5 +1,6 @@
#lang scheme
(require scribble/text
(require xml
scribble/text
scheme/port)
(define-syntax include-template
@ -9,7 +10,17 @@
(lambda ()
(output (include/text p))))]))
(define t list)
(define-syntax include-template/xexpr
(syntax-rules ()
[(_ p)
(string->xexpr (include-template p))]))
(define (string->xexpr s)
(with-input-from-string
s
(lambda ()
(xml->xexpr (document-element (read-xml))))))
(define-syntax in
(syntax-rules ()
[(_ x xs e ...)