racket/collects/web-server/templates.rkt
Jay McCarthy 73232afd99 Adding customization of command-char to web-server/template
This entails adding it to include/text and read-syntax-inside as well.
2013-05-08 10:52:40 -06:00

33 lines
880 B
Racket

#lang racket/base
(require xml
scribble/text
(for-syntax racket/base
racket/list
syntax/parse)
racket/port)
(define-syntax (include-template stx)
(syntax-parse stx
[(_ (~optional (~seq #:command-char command-char:expr)) p:expr)
(quasisyntax/loc stx
(with-output-to-string
(lambda ()
(output (include/text #,@(if (attribute command-char)
(list #'#:command-char #'command-char)
empty)
p)))))]))
(define-syntax include-template/xexpr
(syntax-rules ()
[(_ . p)
(string->xexpr (include-template . p))]))
(define-syntax in
(syntax-rules ()
[(_ x xs e ...)
(for/list ([x xs])
(begin/text e ...))]))
(provide include-template
in)